I have a simple Android Spinner which I fill with a two column list of “icon” and “name”. This works perfect.
ArrayList<HashMap<String, Object>> stationList = new ArrayList<HashMap<String, Object>>();
... // fill stationList
Spinner spinner = (Spinner) findViewById(R.id.stations);
SimpleAdapter adapter = new SimpleAdapter(
this,
stationList,
R.layout.listitem,
new String[] { "icon", "name" },
new int[] {R.id.option_icon, R.id.option_text });
spinner.setAdapter(adapter);
How can I retrieve a row from the list by just knowing the “name”? I do not know the id nor the position in the spinner!
Thanks!
If you want to search the
stationListto find a specific value, you can try something like this: