title: (dynamic) Multiple spinners state/city
body: <p>I have to develop an android view such that i have 2 spinner controls in it, one for state and the second for cities.</p>
  
  <p>My question is, how can I populate the city spinner automatically whenever a state is selected?</p>
  
  <p>What's the logic behind it?</p>
  
  <p>My string.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  &lt;string name="spinner_category"&gt;&lt;/string&gt;
  &lt;string-array name="category_state"&gt;
      &lt;item &gt;kerala&lt;/item&gt;
      &lt;item &gt;tamil nadu&lt;/item&gt;
      &lt;item &gt;Andra Pradesh&lt;/item&gt;
      &lt;item &gt;karnataka&lt;/item&gt;
  &lt;/string-array&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>My main.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
  
      &lt;LinearLayout android:orientation="horizontal"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"&gt;
          &lt;TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:padding="10dip"
              android:text="Select : "/&gt;
          &lt;Spinner android:layout_width="250dip"
              android:layout_height="wrap_content"
              android:id="@+id/spinner_state"/&gt;
      &lt;/LinearLayout&gt;
  
  &lt;LinearLayout android:orientation="horizontal"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"&gt;
          &lt;TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:padding="10dip"
              android:text="Select : "/&gt;
          &lt;Spinner android:layout_width="250dip"
              android:layout_height="wrap_content"
              android:id="@+id/spinner_state"/&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And my activity.java file:</p>
  
  <pre><code>package com.converter;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.ArrayAdapter;
  import android.widget.Spinner;
  
  public class ConverterActivity extends Activity 
  {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          Spinner spinner_s = (Spinner)findViewById(R.id.spinner_state);
          ArrayAdapter&lt;CharSequence&gt; category_adapter = ArrayAdapter.createFromResource(
                  this, R.array.category_array, android.R.layout.simple_spinner_item);
          category_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          spinner_s.setAdapter(category_adapter);
  
      }
  }
  </code></pre>