views:

391

answers:

1

I have a update view, where I need to preselect the value stored in database for a Spinner.

I was having in mind something like this, but the Adapter has no indexOf method, so I am stuck .

void setSpinner(String value)
    {
        int pos=getSpinnerField().getAdapter().indexOf(value);
        getSpinnerField().setSelection(pos);
    }
+1  A: 

I keep a separate ArrayList of all the items in my Spinners. This way I can do indexOf on the ArrayList and then use that value to set the selection in the Spinner.

mbaird
There is no other way, you know of?
Pentium10
Not that I know of.
mbaird
How to set selection to nothing? (if the item is not in the list)
Pentium10