Android : How to poplulate Spinner content based on the selection of previous spinner? -
<string-array name="block"> <item>block a</item> <item>block b</item> <item>block c</item> </string-array> <string-array name="level"> <item>ground floor</item> <item>first floor</item> <item>second floor</item> <item>third floor</item> </string-array> the scenario:
1.if select block or b in blockspinner, content in levelspinner have ground,first , second floor.
2.if select block c in blockspinner, content in levelspinner have item in string array - level
what need handle in code.
try implementing in activity:
public void onitemselected(adapterview<?> parent, view view, int pos, long id) { spinner spinner = (spinner) parent; if(spinner.getid() == r.id.spinner1) //do spinner1 { //fill spinner2 } }
filling spinner programatically recomend this site
Comments
Post a Comment