pop Previous Fragment From Stack - Android android.support.v4.app

Android examples for android.support.v4.app:Fragment

Description

pop Previous Fragment From Stack

Demo Code

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import java.util.List;
import java.util.Stack;

public class Main{

    public static void popPreviousFragmentFromStack(
            FragmentManager fragmentManager, Stack<Fragment> fragmentStack) {
        FragmentTransaction ft = fragmentManager.beginTransaction();
        fragmentStack.lastElement().onPause();
        ft.remove(fragmentStack.pop());//from   w  w  w  . j av  a2s  .  c  o  m
        fragmentStack.lastElement().onResume();
        ft.show(fragmentStack.lastElement());
        ft.commit();
    }

}

Related Tutorials