List of usage examples for android.support.v4.app FragmentTransaction detach
public abstract FragmentTransaction detach(Fragment fragment);
From source file:com.gome.haoyuangong.views.MyFragmentTabHost.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.hide(info.fragment);//??? ft.commit();/*from www . jav a 2 s. c om*/ } } mTabs.add(info); addTab(tabSpec); }
From source file:com.mbientlab.metawear.app.NavigationActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); if (currentFragment != null) { transaction.detach(currentFragment); }// w w w. ja va2s. c o m String newFragmentTag = FRAGMENT_TAGS.get(position); currentFragment = fragmentManager.findFragmentByTag(newFragmentTag); if (currentFragment == null) { try { currentFragment = FRAGMENT_CLASSES.get(newFragmentTag).getConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException("Cannot instantiate fragment", e); } transaction.add(R.id.container, currentFragment, newFragmentTag); } mTitle = newFragmentTag; restoreActionBar(); transaction.attach(currentFragment).commit(); }
From source file:core.september.speechreminder.activities.SpeechReminderActivity.java
@Override public void onUpdate(long id) { ListItemFragment fragment = (ListItemFragment) getSupportFragmentManager() .findFragmentById(R.id.list_item_fragmet); final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.detach(fragment); ft.attach(fragment);/*w w w . j ava2 s . c om*/ ft.commit(); List<Event> eventList = CRUD.getInstance().select(Event.class); fragment.showDetails(id); }
From source file:com.sb.tododemo.widgets.SavedStateFragmentTabHost.java
public void addTab(final TabHost.TabSpec tabSpec, final Class<?> clss, final 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 ww . ja v a 2 s . c o m } } mTabs.add(info); addTab(tabSpec); }
From source file:edu.mit.mobile.android.livingpostcards.MainActivity.java
@Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { final FragmentManager fm = getSupportFragmentManager(); final String tag = (String) tab.getTag(); final Fragment f = fm.findFragmentByTag(tag); if (f != null) { ft.detach(f); }/*from ww w . j ava 2 s. co m*/ }
From source file:me.trashout.activity.base.BaseActivity.java
/** * Refresh current fragment by Tag/* w w w.j ava 2 s . com*/ * * @param fragmentTag */ public void refreshFragment(String fragmentTag) { Fragment frg = null; frg = getSupportFragmentManager().findFragmentByTag(fragmentTag); if (frg != null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.detach(frg); ft.attach(frg); ft.commit(); } }
From source file:fi.ohtu.mobilityprofile.ui.fragments.SettingsFragment.java
private void updateView() { FragmentTransaction tr = getFragmentManager().beginTransaction(); Fragment yourPlaces = getFragmentManager().getFragments().get(1); tr.detach(yourPlaces); tr.attach(yourPlaces);//from w w w . j a va 2s.c o m tr.commit(); }
From source file:eu.trentorise.smartcampus.jp.custom.TabListener.java
public void onTabUnselected(Tab tab, FragmentTransaction ft) { // if (mFragment != null) { // // Detach the fragment, because another one is being attached // ft.detach(mFragment); // }/*from w w w .java 2 s .co m*/ mActivity.getSupportFragmentManager().popBackStack(mTag, FragmentManager.POP_BACK_STACK_INCLUSIVE); if (mFragment != null) { // Detach the fragment, because another one is being attached ft.detach(mFragment); } }
From source file:org.videolan.myvlc.core.gui.about.AboutActivity.java
@Override public void onTabChanged(String newTag) { String oldTag = mCurrentTabTag; /* cosmetics */ FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if (oldTag == "main" && newTag == "licence") { ft.setCustomAnimations(R.anim.anim_enter_right, R.anim.anim_leave_left); } else if (newTag == "main" && oldTag == "licence") { ft.setCustomAnimations(R.anim.anim_enter_left, R.anim.anim_leave_right); }//from w ww .ja va2s . c o m ft.detach(getFragmentFromTag(oldTag)); ft.attach(getFragmentFromTag(newTag)); ft.commit(); mCurrentTabTag = newTag; }
From source file:com.fullpower.changeit.fragments.InstagramFragment.java
public void refreshFragment(int numberOfColums, int position) { Fragment frg = null;/* w w w .j ava 2 s .co m*/ FragmentManager manager = getActivity().getSupportFragmentManager(); WeakReference<Fragment> weakReference = ExploreFragment.mFragments.get(position); if (weakReference != null && weakReference.get() != null) { frg = weakReference.get(); } if (frg == null) { //int pos=position < 1 ? 0 : position - 1; frg = InstagramFragment.newInstance(mList[position], position); } FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); ft.detach(frg); ft.attach(frg); ft.commit(); }