title: How to connect 2 different spinners altogether
body: <p>I am trying to connect 2 spinners together. Meaning, the items inside 2nd spinner will depend on whatever item is chosen for the 1st spinner.</p>
  
  <p>This is the code inside the main java file.</p>
  
  <p>public void onCreate(Bundle savedInstanceState) {</p>
  
  <pre><code>super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  
  Spinner spinner = (Spinner) findViewById(R.id.spinner);
  ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(
          this, R.array.planets_array, android.R.layout.simple_spinner_item);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
  </code></pre>
  
  <p>}</p>
  
  <p>This is the code inside MyOnItemSelectedListener.java</p>
  
  <p>public class MyOnItemSelectedListener implements OnItemSelectedListener {</p>
  
  <pre><code>public void onItemSelected(AdapterView&lt;?&gt; parent,
      View view, int pos, long id) {
    Toast.makeText(parent.getContext()), "The planet is " +
        parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
  }
  
  public void onNothingSelected(AdapterView parent) {
    // Do nothing.
  }
  </code></pre>
  
  <p>}</p>
  
  <p>So the onItemSelected function will print out the item that was chosen in 1st spinner on the screen. However, I can't figure out how to create the 2nd spinner fully based on the value inside 1st spinner.</p>
  
  <p>I know that there should be something needed to be done inside onItemSelected, but I just can't figure it out since I am a newbie in Java Android.</p>
  
  <p>Can you guys assist me on this?</p>
  
  <p>Thank you.</p>