title: Start Android App in a specific tab
body: <p>The question is: I have a <code>TabHost</code> with 4 tabs (see code below) and I got a <code>Button</code> in <code>MainMenuActivity</code> class. The <code>Button</code> is set up with a <code>OnClickListener</code> and if it is clicked I want it to go to the second tab. I have tried with <code>setCurrentTab(1)</code> but that just messed the project up. What can I do?</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.main);
      setTabs() ; 
  }
  private void setTabs()
  {
      addTab("Home", R.drawable.tab_home, MainMenuActivity.class);
      addTab("Calculate", R.drawable.tab_search, SpinnerClass.class);
  
      addTab("Search", R.drawable.tab_home, ScrollView1.class);
      addTab("Premium", R.drawable.tab_search, ScrollView2.class);
  
  }
  
  private void addTab(String labelId, int drawableId, Class&lt;?&gt; c)
  {
      TabHost tabHost = getTabHost();
      Intent intent = new Intent(this, c);
      TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId); 
  
      View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
      TextView title = (TextView) tabIndicator.findViewById(R.id.title);
      title.setText(labelId);
      ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
      icon.setImageResource(drawableId);
  
      spec.setIndicator(tabIndicator);
      spec.setContent(intent);
      tabHost.addTab(spec);
  
  }    
  </code></pre>