add Fragment Stacked - Android android.support.v4.app

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

Description

add Fragment Stacked

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 addFragmentStacked(FragmentManager fragmentManager,
            Fragment fragment, int frameId, String fragmentTag,
            Stack<Fragment> fragmentStack) {
        FragmentTransaction transaction = fragmentManager
                .beginTransaction();/*from  w  w w . j a  v a  2s.c  om*/
        transaction.add(frameId, fragment, fragmentTag);
        fragmentStack.lastElement().onPause();
        transaction.hide(fragmentStack.lastElement());
        fragmentStack.push(fragment);
        transaction.commit();
    }

}

Related Tutorials