0

I have 5 spinners in my layout. Each one is dependent on the previous spinner(s). Due to the limit of OnItemSelectedListener, the current value that is displayed in the spinner cannot be selected.

I am wanting to be able to select a value on my spinner, even if it is already selected/shown.

Here is the cursor for one of my spinners and the XML of one of the spinners:

vType = (Cursor) DataBaseHelper.getPowersportsType();
    startManagingCursor(vType);

        SimpleCursorAdapter powType = new SimpleCursorAdapter(this, 
                android.R.layout.simple_spinner_item, 
                vType,
                new String [] {DataBaseHelper.POWERSPORTS_TYPE},
                new int[] {android.R.id.text1});

        powType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        vTypeSpinner = (Spinner) findViewById(R.id.typeSpinner);
        vTypeSpinner.setAdapter(powType);


                vTypeSpinner.setOnItemSelectedListener(new OnItemSelectedListener(){


                    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int
                        i, long id) {

                            Cursor vTypeChose = (Cursor)(vTypeSpinner.getSelectedItem());
                            if (vTypeChose != null) {
                                String typePicked = vTypeChose.getString(
                                vTypeChose.getColumnIndex(DataBaseHelper.POWERSPORTS_TYPE));
                                vMake = (Cursor) DataBaseHelper.getPowersportsMake(typePicked);
                                powMake.changeCursor(vMake);
                                Log.e("SpinnerTest", "Type Selected: " + vType.getString(vType.getColumnIndex(DataBaseHelper.POWERSPORTS_TYPE)));


                            }
                    }

                    @Override
                    public void onNothingSelected(AdapterView<?> arg0) {
                        // TODO Auto-generated method stub

                    }
                });



<Spinner
    android:id="@+id/typeSpinner"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/textView01"
    android:layout_centerVertical="true"
    android:layout_below="@+id/textView01" />

I have tried many different ways of doing this from answers on this website and none have worked.

EDIT: If it helps, my spinners are being populated from my database.

LukeG224
  • 155
  • 10
  • you can't select a value if it is already selected/shown, if you want get that you must write Custom Adapter – Shayan Pourvatan Dec 27 '13 at 19:48
  • **"Due to the limit of OnItemSelectedListener, the current value that is displayed in the spinner cannot be selected."** - Urrrm, so simply save which item is selected at the time that it is actually selected. Example `int spinnerOneSelection = i;` – Squonk Dec 27 '13 at 20:09
  • @Shayanpourvatan I know that, that is why I am asking this question. – LukeG224 Dec 27 '13 at 20:34
  • @Squonk Once an item is selected, the other spinners in my layout populate, The user must have the ability to select the already selected/show spinner value. Here are some references from other Stack Overflow users: [LINK](http://stackoverflow.com/questions/7975394/how-to-use-android-spinner-like-a-drop-down-list) and [LINK](http://stackoverflow.com/questions/10854329/spinner-onitemselected-not-called-when-selected-item-remains-the-same) They are using custom spinner classes. Whenever I try and use one, I get errors about Spinner cannot be cast to CustomSpinner. – LukeG224 Dec 27 '13 at 20:38

0 Answers0