show And Remove Fragments - Android User Interface

Android examples for User Interface:Fragment

Description

show And Remove Fragments

Demo Code


//package com.java2s;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;

public class Main {
    public static void showAndRemoveFragments(FragmentManager fm,
            Fragment showFragment, Fragment removeFragment,
            int inAnimationId, int outAnimationId) {
        fm.beginTransaction()//from w  ww.j a  v  a 2 s.c  o  m
                .setCustomAnimations(inAnimationId, outAnimationId)
                .remove(removeFragment).show(showFragment)
                .commitAllowingStateLoss();
    }
}

Related Tutorials