Android ActionBar Tabs onclick issue
<p>i have a problem with the onclick event for tabs at the ActionBar.
I want to "outsource" the ActionBar-Tab logic to a class, so that
i can reuse the ActionBar-Tabs-navigation in all activities.</p>

<p>Here is the outsourced "ActionBar-Tab" logic:</p>

<pre><code>public class TabActivity extends Activity implements TabListener 
</code></pre>

<p>{</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab);

    // Set up the ActionBar to show tabs:
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Add Tabs:
    actionBar.addTab(actionBar.newTab().setText("Dashboard").setTabListener(this),0,true);
    actionBar.addTab(actionBar.newTab().setText("Search").setTabListener(this),1,false);
    actionBar.addTab(actionBar.newTab().setText("Map").setTabListener(this),2,false);
}

@Override
public void onTabSelected(Tab arg0, FragmentTransaction arg1) 
{
    switch(arg0.getPosition())
    {
       case 0:
           Intent dashboard = new Intent(this,DashBoardActivity.class);
           startActivity(dashboard);
       break;

       case 1:
           Intent suche = new Intent(this,SucheActivity.class);
           startActivity(suche);
       break;

       case 2:
           // Start Intent
       break;

       case 3:
           // Start Intent
       break;

       case 4:
         // Start Intent
       break;
    }
}

@Override
public void onTabReselected(Tab arg0, FragmentTransaction arg1) {

}

@Override
public void onTabUnselected(Tab arg0, FragmentTransaction arg1) {

}
</code></pre>

<p>}</p>

<p>And here is the DashBoardActivity which extends the TabActivity class:</p>

<pre><code>public class DashBoardActivity extends TabActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dash_board);
}
</code></pre>

<p>}</p>

<p>The DashBoardActivity is also the Launcher Activity for my app.</p>

<p>So, my problem.
When the App starts, the ActionBar navigation is successfully show as expected.
I saw (via Log.i), that when the App starts, the ActionBar's onTabSelected()
is called (without clicking it).</p>

<p>As you can see, i want to start different Activities depending on the
Tab that was clicked. </p>

<p>The problem:
The app starts,- onTabSelected is called automatically on launch,- and then
the Activity "DashBoardActivity.class" get started.
(but the current activity is DashBoardActivity!?!)</p>

<p>The started Activity extends the TabActivity,- but the ActionBar-Tabs
are not show.</p>

<p>Is there a solution ?</p>
