• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps two spinners help

magmag

Lurker
I have two spinners in my activity.
On function onItemSelected(AdapterView<?> parent, View view, int pos, long id)
how is it possible to see the values selected for each spinner.
I have spinner1 and spinner2. How should I compare the values to decide which value is from spinner1 and which from spinner2?
 
The listener is attached to each spinner I presume. This means that each time you select something in any spinner, that onItemSelected method will be called. To figure out which of the spinner have been used, you can use the "view" that is given to identify the spinner (e.g. .getID() ).

But if you need to compare the two selected values only when a value has been selected in both, you either need to use some flags/booleans to check is both are set, or do it somewhere else, simply retrieving the currently selected item from the spinners at that time..

Spinner
 
Back
Top Bottom