how to use Android Spinner with text and value?
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
开发者_StackOverflow中文版
. . . 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.
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.
精彩评论