Note that there are some explanatory texts on larger screens.

plurals
  1. POSpinner items are having no effect on click !!!, the list just remains on the screen
    text
    copied!<p>I have an activity which takes in the bank names and the account number from the user. The bank name and the corresponding account number are stored in the database. Now there are two spinners in another activity , one of them gets the bank names and populates itself with them, the other one gets the account number corresponding to that bank. I am successful in populating the spinners.The only problem I am having is that, the entries in the first spinner(holding the bank names) are not clickable, and so the second spinner becomes useless as well.I am not able to understand as what could be the reason for it. Here is the code for the spinners :</p> <pre><code> // in onCreate() function // for the spinner holding bank name Cursor cursor = myDatabase.getData(); cursor.moveToFirst(); myAdapter = new SimpleCursorAdapter(AddTransaction.this, R.layout.spinnerlayout, cursor, new String[] { DatabaseClass.KEY_BANK_NAME_ID }, new int[] { R.id.bankName }, SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); mySpinner.setAdapter(myAdapter); get_datafrom_spinner = cursor.getString(cursor .getColumnIndex(DatabaseClass.KEY_BANK_NAME_ID)); // Toast.makeText(AddTransaction.this, get_datafrom_spinner, // Toast.LENGTH_LONG).show(); // mySpinner.setOnItemSelectedListener(this); myDatabase.close(); @Override public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub try { myDatabase.open(); int pos = position; Cursor cursor = (Cursor) myAdapter.getItem(pos); bank_name = cursor.getString(cursor // name of the bank // selected .getColumnIndex(DatabaseClass.KEY_BANK_NAME_ID)); myAdapter = new SimpleCursorAdapter(AddTransaction.this, R.layout.spinnerlayout, cursor, new String[] { DatabaseClass.KEY_BANK_NAME_ID, }, new int[] { R.id.bankName }, SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); mySpinner.setAdapter(myAdapter); // Toast.makeText(AddTransaction.this, s, // Toast.LENGTH_SHORT).show(); // returns the account numbers corresponding to this bank name Cursor c = myDatabase.getAccountData(bank_name); c.moveToFirst(); myAdapter_for_account = new SimpleCursorAdapter( AddTransaction.this, R.layout.account_number_spinner, c, new String[] { DatabaseClass.KEY_ACCOUNT_NUMBER_ID }, new int[] { R.id.accNum }, SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); mySpinner_for_account.setAdapter(myAdapter_for_account); // position of the the clicked in the spinner for account int position_account = mySpinner_for_account .getSelectedItemPosition(); Cursor cursor2 = (Cursor) myAdapter_for_account .getItem(position_account); // holds the account number for the spinner item selected account_number_selected = cursor2.getString(cursor2 .getColumnIndex(DatabaseClass.KEY_ACCOUNT_NUMBER_ID)); // Toast.makeText(AddTransaction.this, account_number_selected, // Toast.LENGTH_LONG).show(); Cursor balance = myDatabase .getAmountfor_Account(account_number_selected); balance.moveToFirst(); /* * c = myDatabase.getAmountfor_Account(account_for_spiiner_account); * c.moveToFirst(); */ // get the balance as a string balance_in_account = balance.getString(balance // &lt;-- .getColumnIndex(DatabaseClass.KEY_CURRENT_BALANCE_ID)); // Toast.makeText(AddTransaction.this, balance_in_account, // Toast.LENGTH_SHORT).show(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } myDatabase.close(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload