List of usage examples for android.app FragmentTransaction replace
public abstract FragmentTransaction replace(@IdRes int containerViewId, Fragment fragment, String tag);
From source file:com.louding.frame.ui.FrameActivity.java
/** * Fragment?/*from w ww . j a v a 2 s . c om*/ * * @param resView * ?? * @param targetFragment * ??Fragment */ public void changeFragment(int resView, KJFragment targetFragment) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(resView, targetFragment, targetFragment.getClass().getName()); transaction.commit(); }
From source file:com.brandao.tictactoe.board.BoardActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.board_activity); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.board_activity_coordinator_layout); mToolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(mToolbar);//from ww w . j a v a 2 s. co m getSupportActionBar().setDisplayHomeAsUpEnabled(true); mBoardFragment = (BoardFragment) getFragmentManager().findFragmentByTag(FRAGMENT_TAG_BOARD); if (mBoardFragment == null) { FragmentTransaction t = getFragmentManager().beginTransaction(); mBoardFragment = BoardFragment.newInstance(); t.replace(R.id.board_fragment_container, mBoardFragment, FRAGMENT_TAG_BOARD); t.commit(); } }
From source file:cz.zcu.kiv.eeg.mobile.base.ws.asynctask.FetchReservationsToDate.java
/** * Clears adapter of current data and fills it with fetched reservations. * In process it clears details fragment, so it could not display information about no longer existing reservation. * * @param resultList fetched reservations *//* w ww.ja v a 2 s. c o m*/ @Override protected void onPostExecute(List<Reservation> resultList) { reservationAdapter.clear(); if (resultList != null && !resultList.isEmpty()) { for (Reservation reservation : resultList) { try { reservationAdapter.add(reservation); } catch (Exception e) { setState(ERROR, e); Log.e(TAG, e.getLocalizedMessage(), e); } } } FragmentManager fm = activity.getFragmentManager(); ReservationDetailsFragment details = new ReservationDetailsFragment(); ReservationDetailsFragment frag = (ReservationDetailsFragment) fm .findFragmentByTag(ReservationDetailsFragment.TAG); if (frag != null) { FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.details, details, ReservationDetailsFragment.TAG); ft.commit(); } }
From source file:org.meruvian.midas.core.drawer.NavigationDrawer.java
public void replaceFragment(Fragment fragment, String tag) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.content_frame, fragment, tag).addToBackStack(null).commit(); }
From source file:com.sawyer.advadapters.app.adapters.nfjsonadapter.NFJSONAdapterActivity.java
@Override protected void initFrags() { super.initFrags(); FragmentManager manager = getFragmentManager(); mListFragment = (NFJSONAdapterFragment) manager.findFragmentByTag(TAG_ADAPTER_FRAG); if (mListFragment == null) { mListFragment = NFJSONAdapterFragment.newInstance(); FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.frag_container, mListFragment, TAG_ADAPTER_FRAG); transaction.commit();/*from www . j av a2s . c o m*/ } mAddDialogFragment = (AddJSONArrayDialogFragment) manager.findFragmentByTag(TAG_ADD_DIALOG_FRAG); if (mAddDialogFragment != null) { mAddDialogFragment.setEventListener(this); } }
From source file:de.mgd.simplesoundboard.MainActivity.java
private void initFragments() { FragmentTransaction tx = getFragmentManager().beginTransaction(); if (soundResourceDao.hasCategories()) { tx.replace(R.id.content_nav, new SoundResourceCategoryFragment(), NAVIGATION_FRAGMENT_ID); }/*from w w w . j a v a 2 s. c om*/ tx.replace(R.id.content_root, new SoundResourceListFragment(), CONTENT_FRAGMENT_ID); tx.commit(); }
From source file:com.microsoft.office365.starter.FilesFolders.FileDetailActivity.java
private void updateActionHandler() { // Display the update fragment FileUpdateFragment updateFragment = new FileUpdateFragment(); FragmentManager fragmentManager = getFragmentManager(); android.app.FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.file_detail_container, updateFragment, UPDATE_FRAGMENT_STACK_STATE); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack(UPDATE_FRAGMENT_STACK_STATE); ft.commit();//from www . j av a2 s . com }
From source file:com.sawyer.advadapters.app.adapters.jsonadapter.UnitTestJSONArrayActivity.java
@Override protected void initFrags() { super.initFrags(); FragmentManager manager = getFragmentManager(); mListFragment = (UnitTestJSONArrayFragment) manager.findFragmentByTag(TAG_ADAPTER_FRAG); if (mListFragment == null) { mListFragment = UnitTestJSONArrayFragment.newInstance(); FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.frag_container, mListFragment, TAG_ADAPTER_FRAG); transaction.commit();// w w w . j a v a 2 s.c om } }
From source file:com.sawyer.advadapters.app.adapters.jsonadapter.JSONAdapterActivity.java
@Override protected void initFrags() { super.initFrags(); FragmentManager manager = getFragmentManager(); mListFragment = (JSONAdapterFragment) manager.findFragmentByTag(TAG_ADAPTER_FRAG); if (mListFragment == null) { mListFragment = JSONAdapterFragment.newInstance(); FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.frag_container, mListFragment, TAG_ADAPTER_FRAG); transaction.commit();//from w w w.j ava2s . c om } mAddDialogFragment = (AddJSONArrayDialogFragment) manager.findFragmentByTag(TAG_ADD_DIALOG_FRAG); if (mAddDialogFragment != null) { mAddDialogFragment.setEventListener(this); } }
From source file:org.kymjs.kjframe.ui.FrameActivity.java
/** * Fragment?/*from ww w .ja v a 2s.com*/ * * @param resView * ?? * @param targetFragment * ??Fragment */ public void changeFragment(int resView, SupportFragment targetFragment) { android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(resView, targetFragment, targetFragment.getClass().getName()); transaction.commit(); }