title: How to make 4 spinners dependent of each others value
body: <p>I am new to android and was wondering how you can have 4 spinners on a page, but dependent of each other's value. I am trying to make it so that when you select the value of the first one for example the values of the second spinner might change but then I need the 3rd spinner to depend on the value of the second spinner and the same with the 4th spinner depending on the value of the 3rd spinner (because I have so many possibilities). I have the layout set correctly I just cant get the code in my main class to work right.</p>
  
  <p>I have something similar I found online that describes how to do it with 2 spinners but I need it to have 4.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>package com.bar.example.androidspinnerexample;
   
  import java.util.ArrayList;
  import java.util.List;
   
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.Spinner;
  import android.widget.AdapterView.OnItemSelectedListener;
  import android.widget.Toast;
   
  public class SpinnerEx4Activity extends Activity implements
  OnItemSelectedListener{
  Spinner s1,s2;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_spinner_ex4);
          s1 = (Spinner)findViewById(R.id.spinner1);
          s2 = (Spinner)findViewById(R.id.spinner2);
          s1.setOnItemSelectedListener(this);
      }
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
              long arg3) {
          // TODO Auto-generated method stub
          String sp1= String.valueOf(s1.getSelectedItem());
          Toast.makeText(this, sp1, Toast.LENGTH_SHORT).show();
          if(sp1.contentEquals("Income")) {
              List&lt;String&gt; list = new ArrayList&lt;String&gt;();
              list.add("Salary");
              list.add("Sales");
              list.add("Others");
              ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(this,
                  android.R.layout.simple_spinner_item, list);
              dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
              dataAdapter.notifyDataSetChanged();
              s2.setAdapter(dataAdapter);
          }
          if(sp1.contentEquals("Expense")) {
              List&lt;String&gt; list = new ArrayList&lt;String&gt;();
              list.add("Conveyance");
              list.add("Breakfast");
              list.add("Purchase");
              ArrayAdapter&lt;String&gt; dataAdapter2 = new ArrayAdapter&lt;String&gt;(this,
                  android.R.layout.simple_spinner_item, list);
              dataAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
              dataAdapter2.notifyDataSetChanged();
              s2.setAdapter(dataAdapter2);
          }
           
      }
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          // TODO Auto-generated method stub
           
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>If anyone could show me an example of 4 spinners that would be great. Thanks in advance!</p>