List of usage examples for android.app FragmentTransaction replace
public abstract FragmentTransaction replace(@IdRes int containerViewId, Fragment fragment);
From source file:com.example.android.adrenaland.MainActivity.java
public void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new FragmentHome(); switch (position) { case 0://www .j a va 2 s . c o m fragment = new FragmentHome(); break; case 1: fragment = new FragmentNavigation(); Bundle args = new Bundle(); args.putBoolean(FragmentNavigation.ARG_CLOUD, false); args.putBoolean(FragmentNavigation.ARG_BIG_DROP, false); fragment.setArguments(args); break; case 2: fragment = new FragmentWaitTimes(); break; case 3: fragment = new FragmentShowTimes(); break; case 4: fragment = new FragmentRideInfo(); break; case 5: fragment = new FragmentRollerCoasters(); break; } FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer if (position <= 4) { mDrawerList.setItemChecked(position, true); } mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.masil.android.navigationdrawer.NavigationDrawerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. int id = item.getItemId(); if (mDrawerToggle.onOptionsItemSelected(item)) { if (id == R.id.btn_home) { MasilFragment fragment = new MasilFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.content_frame, fragment); ft.commit();/*from w ww . java2 s . c o m*/ return true; } } return super.onOptionsItemSelected(item); }
From source file:com.masil.android.navigationdrawer.NavigationDrawerActivity.java
private void selectItem(int position) { // update the main content by replacing fragments // Fragment fragment = PlanetFragment.newInstance(position); switch (position) { case 0:// w w w. j a v a2s . co m MasilFragment fragment = new MasilFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.content_frame, fragment); ft.commit(); break; case 1: Toast.makeText(getApplicationContext(), "? ", Toast.LENGTH_SHORT).show(); break; case 2: Toast.makeText(getApplicationContext(), "? ?", Toast.LENGTH_SHORT).show(); break; case 3: Toast.makeText(getApplicationContext(), "? ?", Toast.LENGTH_SHORT).show(); break; } // update selected item title, then close the drawer setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.Candy.ota.CandyOTA.java
private void addShortCutFragment() { FragmentManager fragmentManager = this.getActivity().getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); CandyLinks candyLinks = new CandyLinks(); fragmentTransaction.replace(R.id.linksFragment, candyLinks); fragmentTransaction.commit();/* w w w .j a v a2 s . c o m*/ }
From source file:com.ariesmcrae.eskwela.celebtweet.MainActivity.java
/** Add FeedFragment to Activity */ private FeedFragment addFeedFragment() { FeedFragment feedFragment;// w ww. j a v a2s . c o m feedFragment = new FeedFragment(); FragmentTransaction transaction = mFragmentManager.beginTransaction(); transaction.replace(R.id.fragment_container, feedFragment); transaction.addToBackStack(null); transaction.commit(); mFragmentManager.executePendingTransactions(); return feedFragment; }
From source file:com.slim.ota.SlimOTA.java
private void addShortCutFragment() { FragmentManager fragmentManager = this.getActivity().getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); SlimLinks slimLinks = new SlimLinks(); fragmentTransaction.replace(R.id.linksFragment, slimLinks); fragmentTransaction.commit();/*w w w .j a v a 2s . c o m*/ }
From source file:ngoc.com.pedometer.ui.Activity_Main.java
@Override protected void onCreate(final Bundle b) { super.onCreate(b); startService(new Intent(this, SensorListener.class)); if (b == null) { // Create new fragment and transaction Fragment newFragment = new Fragment_Overview(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this // fragment, // and add the transaction to the back stack transaction.replace(android.R.id.content, newFragment); // Commit the transaction transaction.commit();/* w ww . j a v a2s .c om*/ } }
From source file:com.filemanager.free.activities.Preferences.java
public void donate() { try {/*from www . j av a2 s .c o m*/ getFragmentManager().beginTransaction().remove(p).commit(); } catch (Exception e) { e.printStackTrace(); } String[] s = new String[] { "Minimal Donation", "Medium Donation", "High Donation" }; DonationsFragment donationsFragment = DonationsFragment.newInstance(BuildConfig.DEBUG, true, GOOGLE_PUBKEY, GOOGLE_CATALOG, s, false, null, null, null, false, null, null, false, null); android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.prefsfragment, donationsFragment); transaction.commit(); assert (getSupportActionBar()) != null; getSupportActionBar().setTitle(R.string.donate); }
From source file:it.mobistego.MainActivity.java
@Override public void onMainFragmentGridItemSelected(MobiStegoItem mobiStegoItem) { if (mobiStegoItem != null) { ItemViewFragment viewFragment = new ItemViewFragment(); Bundle args = new Bundle(); viewFragment.setArguments(args); viewFragment.setMobiStegoItem(mobiStegoItem); FragmentTransaction transaction = getFragmentManager().beginTransaction(); Fragment mainFrag = getFragmentManager().findFragmentByTag(Constants.CONTAINER); transaction.replace(mainFrag.getId(), viewFragment); transaction.addToBackStack(null); transaction.commit();//from w w w.ja va 2 s . c om } }
From source file:rtdc.android.presenter.MainActivity.java
public void goToFragment(FragmentType type) { User sessionUser = (User) Cache.getInstance().get("sessionUser"); switch (type) { case CAPACITY_OVERVIEW: fragment = new CapacityOverviewFragment(); if (sessionUser.getPermission().equals(User.Permission.MANAGER)) isAtHome = true;/*from w w w.ja va 2s .c o m*/ break; case ACTION_PLAN: fragment = new ActionPlanFragment(); if (sessionUser.getPermission().equals(User.Permission.USER)) isAtHome = true; break; case MESSAGES: fragment = new MessagesFragment(); break; case MANAGE_UNITS: if (sessionUser.getPermission().equals(User.Permission.MANAGER)) isAtHome = true; fragment = new ManageUnitsFragment(); break; case MANAGE_USERS: fragment = new ManageUsersFragment(); break; case PROFILE: fragment = new ProfileFragment(); break; } // Insert the fragment by replacing any existing fragment FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.main_fragment_wrapper, fragment); transaction.addToBackStack(null); transaction.commit(); }