add Fragment With History - Android User Interface

Android examples for User Interface:Fragment

Description

add Fragment With History

Demo Code


//package com.java2s;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;

public class Main {
    public static void addFragmentWithHistory(Fragment fragment,
            FragmentActivity activity, int fragHolderLayout) {
        FragmentTransaction fragTransaction = activity
                .getSupportFragmentManager().beginTransaction();
        fragTransaction.replace(fragHolderLayout, fragment);
        fragTransaction.addToBackStack(null);
        fragTransaction.commit();//  ww w.  ja v  a2s.  co  m
    }
}

Related Tutorials