I have a Spinner that’s populated using a cursor containing data from a database. It appears that it’s impossible to set the selected item in the spinner using the value of the ID column of a row. And that the only way to set the selected item is by using the position of the row within the dataset. Is this correct? If so, is there a more efficient way of determining the row’s position than by iterating through the dataset using the cursor?
The inefficient (to my mind) way is outlined here.
Thanks much!
First step, create view for your data set, with joins etc.:
Second step:
Then simply:
Results:
To get position by id:
Results:
Hope that help