Setting values and display Text in Android Spinner

Posted by kaibuki on Stack Overflow See other posts from Stack Overflow or by kaibuki
Published on 2010-05-31T07:50:13Z Indexed on 2010/05/31 7:52 UTC
Read the original article Hit count: 1485

Filed under:
|
|
|

Hi,

I need help in setting up value and display text in spinner. as per now I am populating my spinner by array adapter e.g

mySpinner.setAdapter(myAdapter);

and as far as I know after doing this the display text and the value of spinner at same position is same. The other attribute that I can get from spinner is the position on the item.

now in my case I want to make spinner like the drop down box, which we have in .NET.

which holds a text and value.

where as text is displayed and value is at back end. so if I change drop down box , I can either use its selected text or value. but its not happening in android spinner case.

For Example:

Text Value Cat 10 Mountain 5 Stone 9 Fish 14 River 13 Loin 17

so from above array I am only displaying non-living objects text, and what i want is that when user select them I get there value i.e. like when Mountain selected i get 5

I hope this example made my question a bit more clear...

thankx

© Stack Overflow or respective owner

Related posts about java

Related posts about android