title: Problem in Android Spinner inside the Tabbars
body: <p>I am making an application and i am facing a problem.</p>
  
  <p>I am using Tab bars and in one of my Tab bar i am using Spinner.</p>
  
  <p>It loads Perfectly but when i click on it. it gives me:</p>
  
  <pre><code>android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44647ef8 is not valid; is your activity running?
  </code></pre>
  
  <p>This error.</p>
  
  <p>i am using the following code snippet</p>
  
  <pre><code>      ArrayList&lt;String&gt; ageList;
          Spinner age;
          age = (Spinner) findViewById(R.id.country);
  
          ageList = new ArrayList&lt;String&gt;();
          ageList.add("10-20");
          ageList.add("21-35");
          ageList.add("36-60");
          ageList.add("61-100");
          ArrayAdapter&lt;String&gt; adapter2 = new ArrayAdapter&lt;String&gt;(this,
                  android.R.layout.simple_spinner_item, ageList);  //array you are populating  
          adapter2.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
          age.setAdapter(adapter2);
          age.setSelection(0, true);
  </code></pre>
  
  <p>This code work fine when i am using seperate activity not the tab bars. but in tab bars it gives me the above error exception when i click on the spinner to open a list.</p>
  
  <p>Please guide me Thanks a bunch</p>