add Fragment And To Back Stack - Android User Interface

Android examples for User Interface:Fragment

Description

add Fragment And To Back Stack

Demo Code


//package com.java2s;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;

public class Main {
    public static void addFragmentAndToBackStack(
            final FragmentActivity activity, final int containerId,
            final Fragment fragment) {
        activity.getSupportFragmentManager().beginTransaction()
                .add(containerId, fragment).addToBackStack(null)
                .commitAllowingStateLoss();
    }/*from ww  w  .java 2 s.c o  m*/
}

Related Tutorials