Android examples for User Interface:Fragment
go To Next Fragment From Fragment
//package com.java2s; import android.app.Activity; import android.app.Fragment; import android.app.FragmentTransaction; import android.app.ListFragment; public class Main { public static void goToNextFragmentFromFragment(Fragment fragment, int container, boolean addToBackStack, Fragment ctx, String tag) { goToNextFragment(fragment, container, addToBackStack, ctx.getActivity(), tag); }// w w w . ja v a 2 s.c o m public static void goToNextFragmentFromFragment(Fragment fragment, int container, boolean addToBackStack, ListFragment ctx, String tag) { goToNextFragment(fragment, container, addToBackStack, ctx.getActivity(), tag); } public static void goToNextFragment(Fragment fragment, int container, boolean addToBackStack, Activity ctx, String tag) { // Create new fragment and transaction FragmentTransaction transaction = ctx.getFragmentManager() .beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.replace(container, fragment, tag); if (addToBackStack) transaction.addToBackStack(tag); // Commit the transaction transaction.commit(); } }