title: Android - how to auto switch tab in tabhost
body: <p>I have a tabhost with 3 tabs. In tab 3 I have an activity: <code>testActivity</code>. In this activity, I have a button. When I click this button in tab 3, I want the tabhost to switch in tab 1. It should switch automatically; I'm don't click tab 1. How can I do this?</p>
  
  <pre><code>public class TabhostActivity extends Activity{
  public TabHost tabHost;
  private Resources res;
  Intent intent;
  TabHost.TabSpec spec;
  private LocalActivityManager mLocalActivityManager;
  protected int currentTab;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) 
  {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.tabhost);
      tabHost = (TabHost) findViewById(R.id.tabhost);
      mLocalActivityManager = new LocalActivityManager(this, false);
      mLocalActivityManager.dispatchCreate(savedInstanceState);
      tabHost.setup(mLocalActivityManager);
      res = getResources();
      intent = new Intent().setClass(this, SpinnerActivity.class);
      spec = tabHost.newTabSpec("artists");
  
      spec.setIndicator("Sinner", null);
      spec.setContent(intent);
      tabHost.addTab(spec);
  
      intent = new Intent().setClass(this, SonAndroidActivity.class);
      spec = tabHost.newTabSpec("MAIN");
      spec.setIndicator("MAIN",res.getDrawable(R.drawable.ios_logo));
      spec.setContent(intent);
      tabHost.addTab(spec);
  
  
      intent = new Intent().setClass(this, testActiviy.class);
      spec = tabHost.newTabSpec("Spinner");
      spec.setIndicator("TEST", null);
      spec.setContent(intent);
      tabHost.addTab(spec);
  }
  
      tabHost.setOnTabChangedListener(new OnTabChangeListener() {
  
          @Override
          public void onTabChanged(String tabId) {
              Log.v("tag", "click:" + tabHost.getCurrentTab());
              currentTab = tabHost.getCurrentTab();                   
  }
  </code></pre>
  
  <p>and event activity tab 3:</p>
  
  <pre><code>public class testActiviy extends TabhostActivity{
      @Override
      protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.test);
      }
  
      public void btn_onClick(View v)
      {   
          tabHost.setCurrentTab(0);
          Log.v("tag", "clickkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");    
      }
  }
  </code></pre>