0
<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 i select Block A or B in BlockSpinner, the content in the LevelSpinner only will have ground,first and second floor.

2.If i select Block C in BlockSpinner, the content in the LevelSpinner will have all the item in the string array - level

1 Answers1

0

What you need is to handle this in your code.
Try implementing this in your activity:

public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

     Spinner spinner = (Spinner) parent;
     if(spinner.getId() == R.id.spinner1) //do something only for spinner1
     {
       //fill spinner2
     }
}


For filling your spinner programatically i recomend this site

Community
  • 1
  • 1
Pęgaz
  • 46
  • 2