List of usage examples for android.support.v4.app FragmentTransaction detach
public abstract FragmentTransaction detach(Fragment fragment);
From source file:com.miqian.mq.views.FragmentTabHost.java
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commitAllowingStateLoss(); }/* w w w . j a va 2 s . co m*/ } mTabs.add(info); addTab(tabSpec); }
From source file:org.cvasilak.jboss.mobile.app.activities.JBossServerRootActivity.java
@Override protected void onPause() { super.onPause(); // Select proper stack ActionBar.Tab tab = getSupportActionBar().getSelectedTab(); Stack<String> backStack = backStacks.get(tab.getTag()); if (!backStack.isEmpty()) { // Detach topmost fragment otherwise it will not be correctly displayed // after orientation change String tag = backStack.peek(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag); ft.detach(fragment); ft.commit();//from w w w .j a v a2 s . co m } }
From source file:com.lll.library.view.MainFragmentTabHost.java
public void addTab(TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This // shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit();//from w w w . ja v a2s . com } } mTabs.add(info); addTab(tabSpec); }
From source file:com.example.mr_zyl.project.pro.base.view.MyFragmentTabHost.java
public void addTab(TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit();/*from w w w.j a v a 2 s .c o m*/ } } mTabs.add(info); addTab(tabSpec); }
From source file:ru.zabbkit.android.ui.views.FixedFragmentTabHost.java
public final void addTab(final TabHost.TabSpec tabSpec, final Class<?> clss, final Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit();/*from ww w . java 2s . c o m*/ } } mTabs.add(info); addTab(tabSpec); }
From source file:com.ustc.dystu.dandelion.fragment.BaseFragmentTabHost.java
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit();//from w w w . j a va2 s .c o m } } mTabs.add(info); addTab(tabSpec); }
From source file:com.anlddev.customwidget.widget.AFragmentTabHost.java
public void addTab(@NonNull TabHost.TabSpec tabSpec, @NonNull Class<?> clss, @Nullable Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); final String tag = tabSpec.getTag(); final TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { final FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit();/*from w w w . j a v a 2 s.com*/ } } mTabs.add(info); addTab(tabSpec); }
From source file:com.suning.mobile.ebuy.lottery.utils.view.FragmentTabHostAllowLoseState.java
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commitAllowingStateLoss(); }/*from ww w .j a v a2 s. c om*/ } mTabs.add(info); addTab(tabSpec); }
From source file:com.android.util.widget.FragmentTabHost.java
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit();//w ww.j av a 2 s . co m } } mTabs.add(info); addTab(tabSpec); }
From source file:com.example.dj0708.androiddemo20151224.custom.CustomFragmentTabHost.java
public void removeFragment(String tag) { Fragment mFragment = mFragmentManager.findFragmentByTag(tag); if (mFragment != null) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(mFragment); ft.commitAllowingStateLoss();/*w ww. j a v a 2s. c o m*/ } }