why cant my fragments be added to back stack?
@Override
public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) {
FragmentTransaction
The only problem in your code is that you 'correctly' create a transaction, but then you never use it. The supplied transaction FragmentTransaction ft
cannot be added to the backstack because it is not supported by the listener, however this should work:
@Override
public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) {
ListFragment newListFragment = new ListFragment();
Fragment newFragment = new EntryFrag();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.frameOne, newListFragment);
transaction.replace(R.id.frameTwo, newFragment);
transaction.addToBackStack(null);
transaction.commit();
}
Note the use of transaction.replace(...
vice ft.replace(...
also you must commit()
this yourself, as you properly did, because TabListener will only auto-commit FragmentTransaction ft
Also, you can read about adding to the back stack not being supported in the TabListener API docs here: http://developer.android.com/reference/android/app/ActionBar.TabListener.html