I have 3 fragments and an activity. I want to enable tabs on the ActionBar and assign a Fragment to each of the 3 tabs. How do I hook that up cor
@Override
public void onTabSelected(ActionBar.Tab tab, android.support.v4.app.FragmentTransaction fragmentTransaction) {
// Check if the fragment is already initialized
if (mFragment == null) {
// If not, instantiate and add it to the activity
// Toast.makeText(getApplicationContext(),"TAb "+tab.getPosition(),Toast.LENGTH_LONG).show();
if(tab.getPosition() == 1) {
mFragment = new HolderFragment();
fragmentTransaction.add(android.R.id.content, mFragment, mTag);
}
else if(tab.getPosition() == 0)
{
mFragment = new FragmentKnowledge();
fragmentTransaction.add(android.R.id.c`enter code here`ontent, mFragment, mTag);
}
/*else
{
mFragment = Fragment.instantiate(mActivity, mClass.getName());
fragmentTransaction.add(android.R.id.content, mFragment, mTag);
}
*/
} else {
// If it exists, simply attach it in order to show it
fragmentTransaction.attach(mFragment);
}
}