Fragments override error
<p>Hi I am a beginner with fragments and I realize that in order for the fragments to override I need to add it programmatically which I did.  However when I do this, the first 2 or so times I click around on each tab it still doesn't override correctly. Only after about 3 clicks it does so correctly. Her is my code: </p>

<pre><code>public class LeaderboardUI extends FragmentActivity {

    Tab tab;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_leaderboard_ui);
        ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        ActionBar.Tab singlePlayerTab = actionBar.newTab().setText("Singleplayer");
        ActionBar.Tab multiPlayerTab = actionBar.newTab().setText("Multiplayer");

        Fragment singlePlayerFragment = new SingleplayerTab();
        Fragment multiPlayerFragment = new MultiplayerTab();

        singlePlayerTab.setTabListener(new LBTabListener(singlePlayerFragment));
        multiPlayerTab.setTabListener(new LBTabListener(multiPlayerFragment));

        actionBar.addTab(singlePlayerTab);
        actionBar.addTab(multiPlayerTab);

        getSupportFragmentManager().beginTransaction()
        .add(R.id.leaderboard_layout, new SingleplayerTab()).commit();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_leaderboard_ui, menu);
        return true;
    }

    private class LBTabListener implements ActionBar.TabListener {

        private Fragment currentFragment;

        public LBTabListener(Fragment fragment) {
            currentFragment = fragment;
        }

        @Override
        public void onTabReselected(Tab tab, android.app.FragmentTransaction ft) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) {
            // TODO Auto-generated method stub
            getSupportFragmentManager().beginTransaction()
            .replace(R.id.leaderboard_layout, currentFragment).commit();
        }

        @Override
        public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) {
            // TODO Auto-generated method stub
//          getSupportFragmentManager().beginTransaction()
//          .detach(currentFragment).commit();

        }
    }
}
</code></pre>
