List of usage examples for android.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
From source file:com.zftlive.android.sample.fadingactionbar.NavigationDrawerActivity.java
@SuppressLint("NewApi") private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new SampleFragment(); Bundle args = new Bundle(); args.putInt(SampleFragment.ARG_IMAGE_RES, mCityImages[position]); args.putInt(SampleFragment.ARG_ACTION_BG_RES, R.drawable.ab_background); fragment.setArguments(args);//from ww w .j a v a 2 s.c o 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(mCityNames[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.example.actionbarfragement_demo.MainActivity.java
public void addMenu() { Fragment fragment = new MenuFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.left_drawer, fragment).commit(); }
From source file:com.example.actionbarfragement_demo.MainActivity.java
public void addFragment() { Fragment fragment = new FirstFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); }
From source file:com.google.android.apps.santatracker.doodles.PineappleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view); // Check for game direct launch DoodleConfig config;//from w ww . j a va 2s . c o m if (getIntent() != null && getIntent().hasExtra(LaunchDecisionMaker.START_GAME_KEY)) { config = new DoodleConfig(getIntent().getExtras(), null); } else { throw new IllegalStateException("Extra START_GAME_KEY required"); } // [ANALYTICS] mAnalytics = FirebaseAnalytics.getInstance(this); String gameKey = getIntent().getStringExtra(LaunchDecisionMaker.START_GAME_KEY); switch (gameKey) { case LaunchDecisionMaker.WATERPOLO_GAME_VALUE: MeasurementManager.recordScreenView(mAnalytics, getString(R.string.analytics_screen_waterpolo)); break; case LaunchDecisionMaker.RUNNING_GAME_VALUE: MeasurementManager.recordScreenView(mAnalytics, getString(R.string.analytics_screen_running)); break; case LaunchDecisionMaker.SWIMMING_GAME_VALUE: MeasurementManager.recordScreenView(mAnalytics, getString(R.string.analytics_screen_swimming)); break; } appInvitesFragment = AppInvitesFragment.getInstance(this); logger = new PineappleDebugLogger(); Fragment fragment = LaunchDecisionMaker.makeFragment(this, config, logger); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.add(R.id.activity_wrapper, fragment, "menu"); fragmentTransaction.commit(); }
From source file:org.djodjo.acaptcha.example.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.container, PlaceholderFragment.newInstance(position)) .commit();//from ww w . j ava 2 s. co m }
From source file:com.breadwallet.tools.animation.BRAnimator.java
/** * Animate the transition on burgerButton/MenuButton pressed *//* w ww .j av a 2s . c om*/ public static void pressMenuButton(final MainActivity context) { try { if (context == null) return; ((BreadWalletApp) context.getApplication()).cancelToast(); final FragmentManager fragmentManager = context.getFragmentManager(); if (level == 0) { if (PLATFORM_ON) new Thread(new Runnable() { @Override public void run() { HTTPServer.startServer(); } }).start(); level++; CustomPagerAdapter.adapter.showFragments(false, context); context.setBurgerButtonImage(BRConstants.CLOSE); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); FragmentSettingsAll to = (FragmentSettingsAll) fragmentManager .findFragmentByTag(FragmentSettingsAll.class.getName()); if (to == null) to = new FragmentSettingsAll(); fragmentTransaction.add(R.id.main_layout, to, FragmentSettingsAll.class.getName()); fragmentTransaction.commit(); final FragmentSettingsAll finalTo = to; new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(0, 0, 1920, 0); trans.setDuration(500); trans.setInterpolator(new DecelerateOvershootInterpolator(3f, 0.5f)); View view = finalTo.getView(); if (view != null) view.startAnimation(trans); } }, 1); InputMethodManager keyboard = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); if (keyboard != null) keyboard.hideSoftInputFromWindow( CustomPagerAdapter.adapter.mainFragment.addressEditText.getWindowToken(), 0); } else if (level == 1) { if (PLATFORM_ON) new Thread(new Runnable() { @Override public void run() { HTTPServer.stopServer(); } }).start(); level--; context.setBurgerButtonImage(BRConstants.BURGER); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.from_top, R.animator.to_bottom); FragmentSettingsAll fragmentSettingsAll = (FragmentSettingsAll) fragmentManager .findFragmentByTag(FragmentSettingsAll.class.getName()); fragmentTransaction.remove(fragmentSettingsAll); fragmentTransaction.commit(); CustomPagerAdapter.adapter.showFragments(true, context); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.flyingmain.CachingImage.util.ImageCache.java
/** * Locate an existing instance of this Fragment or if not found, create and * add it using FragmentManager.//w w w.ja va 2 s. c om * * @param fm The FragmentManager manager to use. * @return The existing instance of the Fragment or the new instance if just * created. */ private static RetainFragment findOrCreateRetainFragment(android.app.FragmentManager fm) { //BEGIN_INCLUDE(find_create_retain_fragment) // Check to see if we have retained the worker fragment. RetainFragment mRetainFragment = (RetainFragment) fm.findFragmentByTag(TAG); // If not retained (or first time running), we need to create and add it. if (mRetainFragment == null) { mRetainFragment = new RetainFragment(); fm.beginTransaction().add(mRetainFragment, TAG).commitAllowingStateLoss(); } return mRetainFragment; //END_INCLUDE(find_create_retain_fragment) }
From source file:com.ptr.foldingpanelayout.sample.FoldingPaneLayoutActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new AnimalFragment(); Bundle args = new Bundle(); args.putInt(AnimalFragment.ARG_ANIMAL_NUMBER, position); fragment.setArguments(args);/*from w w w . j ava 2 s .c o m*/ FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mPaneList.setItemChecked(position, true); setTitle(mAnimalTitles[position]); mPaneLayout.closePane(); }
From source file:com.SpitsinStafichuk.vkazam_remastered.DrawerActivity.java
@Override public void onNavigationDrawerItemSelected(VkazamDrawerAdapterElement element, int position) { if ((element != null) && (element.getOpeningFragmentName() != null)) { // update the main content by replacing fragments FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.container, getFragmentInstanceByName(element.getOpeningFragmentName())).commit(); }//from w ww . j av a 2s . co m }
From source file:cafe.com.navigationdrawer.NavigationDrawerActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment;/*from ww w .j a v a2 s .co m*/ int viewId; switch (position) { case 0: viewId = R.layout.fragment_listview; fragment = new HomeFragment(); break; default: viewId = R.layout.activity_scrollview; fragment = new SampleFragment(); } Bundle args = new Bundle(); args.putInt(SampleFragment.ARG_IMAGE_RES, mMenuImages[position]); args.putInt(SampleFragment.ARG_ACTION_BG_RES, R.drawable.ab_background); args.putInt(SampleFragment.ARG_LAYOUT_ID, viewId); 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(mMenuNames[position]); mDrawerLayout.closeDrawer(mDrawerList); }