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);
}
Suppose your
Spinneris namedmSpinner, and it contains as one of its choices: “some value”.To find and compare the position of “some value” in the Spinner use this: