title: how to make spinner depends on another spinner
body: <p>I'm building a simple app for android which consists of spinners and edittext.
  question is I have 2 spinners with arrays in an adapter<br/><br/>
  <strong>Spinner 1</strong></p>
  
  <pre><code> ArrayAdapter adapter1 = ArrayAdapter.createFromResource(this,R.array.kendaraan_arrays,android.R.layout.simple_spinner_item);
      spKendaraan.setAdapter(adapter1);
  </code></pre>
  
  <p>what I want is arrays from spinner 2 is depends on what i select in spinner 1<br/><br/>
  <strong>Spinner 2</strong><br></p>
  
  <pre><code>@Override
      public void onItemSelected (AdapterView &lt; ? &gt; adapterView, View view,int position, long id){
      if (spKendaraan.getSelectedItem().equals("Mobil")) {
          Toast.makeText(getApplicationContext(), "Mobil dipilih", Toast.LENGTH_SHORT).show();
          ArrayAdapter adapter2 = ArrayAdapter.createFromResource(this, R.array.pelanggaran_mobil, android.R.layout.simple_spinner_item);
          spPelanggaran.setAdapter(adapter2);
      } else {
          ArrayAdapter adapter2 = ArrayAdapter.createFromResource(this, R.array.pelanggaran_motor, android.R.layout.simple_spinner_item);
          spPelanggaran.setAdapter(adapter2);
      }
  }
  </code></pre>
  
  <p>my code above doesn't work, am I making logic/method mistakes?</p>
  
  <p>tl;dr<br/></p>
  
  <pre><code>if spinnerA == x{
  spinnerB = m
  }
  else {
  spinnerB = n
  }
  </code></pre>
  
  <p>since i'm new in android, any example would be very appreciated.</p>