title: setCurrentTab not working
body: <p>For some reason setCurrentTab is not switching tabs after the first time.
  This is the code that I use.</p>
  
  <pre><code>private OnClickListener buttonListener = new OnClickListener(){
  
      @Override
      public void onClick(View v) {
          tabHost.setCurrentTab(Integer.parseInt((String) v.getTag()));
  
      }
  };
  </code></pre>
  
  <p>It is connected to buttons each of which have a tag that equals the number of of tab to be shown.
  When the button is clicked the first time and this method is called then the tab shows up. I can also see that it executes the code that creates the tab contents.</p>
  
  <p>However, once a tab has been shown once and I have moved to another one, clicking back to it doesn't work.
  The method is definitely called and the tag is also correct. I put in commands to print to the log to confirm that. Also, it works first time round so must be okay.</p>
  
  <p>Any idea?</p>
  
  <p>Full code:</p>
  
  <pre><code>public class TestTabs extends TabbedScreen implements TabHost.TabContentFactory{
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          initTabs();
      }
  
      @Override
      protected void initTabs() {
  
          addTab("0",this);
          addTab("1",this);
          addTab("2",this);
          addTab("3",this);
  
      }
  
      /*
       * 
       * @param extras The Bundle received in onCreate when this class is first created, and which contains the initial set of objects to be displayed.
       * @return An array containing all of the objects in the list.
       */
      protected Serializable[] getDataArray(Bundle extras) {
          int size = extras.size();
          Serializable[] data = new Serializable[size];
          for (int i = 0; i &lt; size; i++) {
              data[i] = extras.getSerializable(Integer.toString(i));
          }
  
          return data;
      }
  
      @Override
      public View createTabContent(String tag) {
  
  
          // Get the data returned from the servelet and display it in the ListView
          Log.d("TestTabs","createTabContent");
           ListView lv = (ListView) findViewById(R.id.list_view);
           List&lt;String&gt; list1Strings = new ArrayList&lt;String&gt;();
           switch (Integer.parseInt(tag)){
              case 0:
                  Log.d("TestTabs","Case 0");
                  lv.setAdapter(new MyAdapter(this,lv,null));
                  break;
  
              case 1:
  
                  Log.d("TestTabs","Case 1");
                  list1Strings.add("Item 21");
                  list1Strings.add("Item 22");
                  list1Strings.add("Item 23");
                  list1Strings.add("Item 24");
                  lv.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, list1Strings));
                  break;
  
              case 2:
  
                  Log.d("TestTabs","Case 2");
                  list1Strings.add("Item 31");
                  list1Strings.add("Item 32");
                  list1Strings.add("Item 33");
                  list1Strings.add("Item 34");
                  lv.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, list1Strings));
                  break;      
  
              case 3:
  
                  Log.d("TestTabs","Case 3");
                  list1Strings.add("Item 41");
                  list1Strings.add("Item 42");
                  list1Strings.add("Item 43");
                  list1Strings.add("Item 44");
                  lv.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, list1Strings));
                  break;      
          }
  
          return lv;
      }
  
  
      protected void addTab(String tabName, TabHost.TabContentFactory tabFactory){
          TabSpec tabSpec = tabHost.newTabSpec(tabName);
          tabSpec.setIndicator(tabName);                // Don't set tab layout since we are going to make it invisible
          tabSpec.setContent(tabFactory);
          tabHost.addTab(tabSpec);
  
          addButton(tabName);
  
  
      }
  
      protected void addButton(String tabName){
          Button button = (Button) buttonHolder.getChildAt(nextChild);
          button.setText(tabName);
          button.setVisibility(View.VISIBLE);
          button.setOnClickListener(buttonListener);
          nextChild--;
      }
  
  
      private OnClickListener buttonListener = new OnClickListener(){
  
          @Override
          public void onClick(View v) {
              v.setBackgroundResource(R.drawable.tab_selected);
              tabHost.setCurrentTab(Integer.parseInt((String) v.getTag()));
              Log.d("TabbedScreen","Set tab to " + v.getTag());
              View view;
              for (int i=0; i&lt; childCount; i++)
                  if ((view = buttonHolder.getChildAt(i)) != v){
                      view.setBackgroundResource(R.drawable.button_tab);
                      view.invalidate();
                  }
  
          }
      };
  }
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>       &lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  
    &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:roundedListView="http://schemas.android.com/apk/res/com.applicat.meuchedet"
      android:id="@android:id/tabhost"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
         android:layout_below="@id/content_screen_user_details"&gt;
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"&gt;
          &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content"&gt;
              &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" 
                  android:layout_height="wrap_content" android:visibility="gone"/&gt;            
              &lt;LinearLayout android:id="@+id/tabButtons" android:layout_width="wrap_content" android:layout_height="20dip"&gt;
                  &lt;Button android:layout_height="wrap_content" android:layout_width="0dip" 
                      android:layout_weight="1.0" android:id="@+id/button3" 
                      android:background="@drawable/button_tab" android:visibility="invisible"
                      android:tag="3"/&gt;
                  &lt;Button android:layout_height="wrap_content" android:layout_width="0dip" 
                      android:layout_weight="1.0" android:id="@+id/button2" 
                      android:background="@drawable/button_tab" android:visibility="invisible"
                       android:tag="2"/&gt;
                  &lt;Button android:layout_height="wrap_content" android:layout_width="0dip" 
                      android:layout_weight="1.0" android:id="@+id/button1" 
                      android:background="@drawable/button_tab" android:visibility="invisible"
                      android:tag="1"/&gt;
                  &lt;Button android:layout_height="wrap_content" android:layout_width="0dip" 
                      android:layout_weight="1.0" android:id="@+id/button0" 
                      android:background="@drawable/tab_selected" android:visibility="invisible"
                      android:tag="0"/&gt;
              &lt;/LinearLayout&gt; 
          &lt;/FrameLayout&gt;
  
          &lt;FrameLayout
              android:id="@android:id/tabcontent"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"&gt;
          &lt;com.applicat.meuchedet.views.RoundedListView
          android:id="@+id/list_view"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:paddingLeft="2dip" 
          android:paddingRight="2dip" 
          android:dividerHeight="1dip"
          android:footerDividersEnabled="true"
          android:listSelector="@drawable/listview_selected_item_background"
          android:fadingEdge="none"
          android:cacheColorHint = "#00000000"
          roundedListView:radius="20"
          roundedListView:border="2"
          /&gt;
          &lt;/FrameLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/TabHost&gt;
  </code></pre>
  
  <p>Edit:</p>
  
  <p>I was wondering if the problem is in the row: </p>
  
  <pre><code>ListView lv = (ListView) findViewById(R.id.list_view);
  </code></pre>
  
  <p>Am I getting back the same object each time?
  If so, how do I get a new one each time based on the one defined in the FrameLayout.</p>