public void onTabSelected(Tab tab, FragmentTransaction ft) { Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } if (!tab.getText().equals(mContext.getString(R.string.tab_sd))) { ActionMode actionMode = ((FileExplorerTabActivity) mContext).getActionMode(); if (actionMode != null) { actionMode.finish(); } } }
@Override public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { currentTab = (String) tab.getText(); // Check if the fragment is already initialized if (mFragment == null) { // If not, instantiate and add it to the activity mFragment = android.app.Fragment.instantiate(mActivity, mClass.getName()); ft.add(android.R.id.content, mFragment, mTag); } else { // If it exists, simply attach it in order to show it ft.attach(mFragment); } }