views:

237

answers:

1

dear friends,

i want to use Android spinner with following data. Spinner will display only text data not code.

code , text

1 , a
2, b
3,c

. . . etc

i have stored above comma seperated data in same activity class (Hard coded form) now if user selects "a" from the dropdown then it should get its code rather then text.

can any one guide me how to achieve this?

any help would be appriciated.

A: 
static final String[] LANGUAGE = new String[]
     {
        "English","Urdu","French","Spanish"

     };

Spinner ddltimezone=(Spinner)findViewById(R.id.ddlTimeZone);

 ArrayAdapter<String> adapter_time = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,TIME_ZONE); 
             adapter_time.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
             ddltimezone.setAdapter(adapter_time);


int indexlanguage = ddllanguage.getSelectedItemPosition() + 1;

and thats it. we have property of getting selecteditem position which sovled my problem.

UMMA
if you are using your own code against each text value then you will have to use hashMap technique.
UMMA