List of usage examples for android.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
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();/*w ww. ja v a 2 s. c o m*/ }
From source file:de.anycook.einkaufszettel.activities.MainActivity.java
private void selectMenuItem(int position) { title = menuTitles[position];/*from w ww . j a v a 2s .c o m*/ Bundle bundle = new Bundle(); Fragment fragment; switch (position) { case 0: fragment = new GroceryListFragment(); break; case 1: fragment = new RecipeFragment(); break; case 2: fragment = new DiscoverFragment(); bundle.putString("type", "new"); break; case 3: fragment = new DiscoverFragment(); bundle.putString("type", "tasty"); break; case 4: startBrowser(); return; case 5: fragment = new SettingsFragment(); break; default: return; } fragment.setArguments(bundle); // update the main content by replacing fragments FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).addToBackStack(title).commit(); // update selected item and title, then close the drawer drawerList.setItemChecked(position, true); drawerLayout.closeDrawer(drawerList); invalidateOptionsMenu(); }
From source file:me.pzheng.conn.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { FragmentManager fm = getFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); Fragment fragment;// w w w.j a v a 2s.c om fragment = fm.findFragmentByTag(SettingsFragment.TAG); if (fragment == null) { fragment = new SettingsFragment(); } transaction.replace(R.id.container, fragment, SettingsFragment.TAG); transaction.addToBackStack(null); transaction.commit(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.example.android.archilok.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = null;/*from w ww. j a va 2 s. c o m*/ switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new CategoriesFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new MapsFragment(); break; case 4: fragment = new SettingsFragment(); break; } Bundle args = new Bundle(); //Arguments send system //args.putInt(SettingsFragment.ARG_PLANET_NUMBER, position); //fragment.setArguments(args); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); //setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.kupepia.piandroidagent.ui.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new ActivityDetailFragment(); Bundle args = new Bundle(); args.putInt(ActivityDetailFragment.FEATURE_ID, position); fragment.setArguments(args);// w ww . ja v a2 s . co m FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(AppContent.ITEMS.get(position).toString()); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.ckt.vas.miles.ui.activities.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment;//w w w . ja v a 2 s. c om if (position == 0) {//? fragment = new MainViewFragment(); } else if (position == 1) {// fragment = new LocationRecordFragment(); } else { fragment = new NearRecordsFragment(); } FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:nl.saxion.weact.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments String action = mPlanetTitles[position]; Fragment fragment;/*w w w . j av a 2 s.co m*/ if (action.equals("Profiel aanpassen")) { fragment = new ProfileAanpassen(); } else { fragment = new PlanetFragment(); Bundle args = new Bundle(); args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(args); // fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // // // update selected item and title, then close the drawer // mDrawerList.setItemChecked(position, true); // setTitle(mPlanetTitles[position]); // mDrawerLayout.closeDrawer(mDrawerList); } FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:org.technovanza.technovanza14.MainActivity_Nav_SideBar.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new TabFragment(); Bundle args = new Bundle(); args.putInt(TabFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(args);//from w w w .j av a 2 s . com FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.example.daniel.koerelogbogapp.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getFragmentManager(); if (position == 1) { fragmentManager.beginTransaction().replace(R.id.mainFragmentContainer, viewEntriesFragment).commit(); } else if (position == 2) { CreateEntryFragment c = new CreateEntryFragment(); c.setActivity(this); fragmentManager.beginTransaction().replace(R.id.mainFragmentContainer, c).commit(); } else if (position == 3) { //TODO make this go to detailView // Fragment fragment = }/* w w w . j av a 2 s .c o m*/ }
From source file:com.bewareofraj.mytvtracker.MainActivity.java
private void selectItem(int position) { String[] items = getResources().getStringArray(R.array.main_menu_items); if (items[position].equals("Watch List")) { WatchListFragment fragment = new WatchListFragment(); FragmentManager fm = getFragmentManager(); fm.beginTransaction().replace(R.id.content_frame, fragment).commit(); } else if (items[position].equals("Search")) { SearchFragment fragment = new SearchFragment(); FragmentManager fm = getFragmentManager(); fm.beginTransaction().replace(R.id.content_frame, fragment).commit(); }/*w w w.j a v a 2 s . c o m*/ // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mMenuItems[position]); mDrawerLayout.closeDrawer(mDrawerList); }