Example usage for android.support.v4.app FragmentTransaction addToBackStack

List of usage examples for android.support.v4.app FragmentTransaction addToBackStack

Introduction

In this page you can find the example usage for android.support.v4.app FragmentTransaction addToBackStack.

Prototype

public abstract FragmentTransaction addToBackStack(String name);

Source Link

Document

Add this transaction to the back stack.

Usage

From source file:Main.java

public static void replaceFragmentToActivity(FragmentManager fragmentManager, Fragment fragment, int frameId) {
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(frameId, fragment);
    transaction.addToBackStack(null);
    transaction.commit();/*from  w ww .  ja  v a2s .com*/
}

From source file:Main.java

/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *
 *//*from w w  w. j a v a 2  s. com*/
public static void addFragmentToBackstackActivity(@NonNull FragmentManager fragmentManager,
        @NonNull Fragment fragment, int frameId) {
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.addToBackStack(null);
    transaction.commit();
}

From source file:Main.java

public static void addFragmentToActivity(FragmentManager fragmentManager, Fragment fragment,
        int containerViewId) {
    FragmentTransaction transition = fragmentManager.beginTransaction();
    transition.replace(containerViewId, fragment);
    transition.addToBackStack(null);
    transition.commit();//from  ww w  .j  a  va 2s.c om
}

From source file:com.kii.util.ViewUtil.java

/**
 * replace with next fragment//from  www  .j a v a  2  s . c om
 * @param manager is fragment manager
 * @param next is fragment you want to replace with
 * @param addBackstack true : add current fragment to backstack
 */
public static void toNextFragment(FragmentManager manager, Fragment next, boolean addBackstack) {
    if (manager == null) {
        return;
    }
    FragmentTransaction transaction = manager.beginTransaction();
    if (addBackstack) {
        transaction.addToBackStack("");
    }
    transaction.replace(R.id.main, next);
    transaction.commit();
}

From source file:Main.java

public static void remplaceFragment(FragmentActivity activity, Fragment newFragment, int fragmentId) {
    FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction();
    transaction.replace(fragmentId, newFragment);
    transaction.addToBackStack(null);
    transaction.commit();/*  w w w. j  a  va2  s.c om*/
}

From source file:com.example.angelina.travelapp.util.ActivityUtils.java

/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *
 *///from   w  ww . j a v  a  2  s .c  o  m
public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment,
        int frameId, @NonNull String fragmentName) {
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.addToBackStack(fragmentName);
    transaction.commitAllowingStateLoss();
}

From source file:Main.java

/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *
 *//*from   w  ww.  j ava2 s  . c o  m*/
public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment,
        int frameId, @NonNull String fragmentName) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.addToBackStack(fragmentName);
    transaction.commit();
}

From source file:com.esri.android.ecologicalmarineunitexplorer.util.ActivityUtils.java

/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *
 *//*ww w . j a  v a2 s  .c  o m*/
public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment,
        int frameId, @NonNull String fragmentName) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.addToBackStack(fragmentName); //don't need this if we're not adding more than one fragment
    transaction.commit();
}

From source file:Main.java

public static void addFragment(Fragment newFragment, boolean callBack, String sTag,
        FragmentManager fragmentManager, int frameID) {
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.add(frameID, newFragment, sTag);//  w  w  w.  j a va2s.c om
    if (callBack) {
        ft.addToBackStack(null);
    } else {
        clearBackStack(fragmentManager);
    }
    ft.commit();
}

From source file:can.yrt.onebusaway.SituationFragment.java

static void show(SherlockFragmentActivity activity, ObaSituation situation) {
    FragmentManager fm = activity.getSupportFragmentManager();

    Bundle args = new Bundle();
    args.putString(TITLE, situation.getSummary());
    // We don't use the stop name map here...we want the actual stop name.
    args.putString(DESCRIPTION, situation.getDescription());

    // Create the list fragment and add it as our sole content.
    SituationFragment content = new SituationFragment();
    content.setArguments(args);//from www .  j  ava2 s  .  c o  m

    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(android.R.id.content, content);
    ft.addToBackStack(null);
    ft.commit();
}