Android examples for User Interface:Fragment
replace Content Fragment
//package com.java2s; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; public class Main { public static void replaceContentFragment(FragmentActivity activity, final int containerId, Fragment fragment) { FragmentManager manager = activity.getSupportFragmentManager(); manager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); manager.beginTransaction().replace(containerId, fragment) .commitAllowingStateLoss(); }/*w w w. j a v a2 s. co m*/ }