I have a spinner dropdown in android and it is populated with list of names as text and ID as value. Now the issue is I have a textbox where user inputs string and on button click item with the name like textbox string should get automatically selected. I searched on google , but couldn't find anything useful. I used
drpMaterial.setSelection(p);
but it works on index, I was looking for something which will work on text not the value in spinnner dropdown.
My code for populating spinner dropdown:
Itm=new CItem( "-1", "Select Material" );
lstItm.add(Itm);
for(int i=0; i < lengthJsonArr; i++) {
jsonmain = j.getJSONObject(i);
Itm=new CItem(jsonmain.getString("ID"),jsonmain.getString("Text"));
lstItm.add(Itm);
}
if(lstItm.size()>0) {
ArrayAdapter<CItem> adapterProj = new ArrayAdapter<CItem>(myactivity, android.R.layout.simple_spinner_item, lstItm);
drpProj.setAdapter(adapterProj);
}