show And Hide Fragments - Android User Interface

Android examples for User Interface:Fragment

Description

show And Hide Fragments

Demo Code


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

public class Main {
    public static void showAndHideFragments(FragmentManager fm,
            Fragment showFragment, Fragment hideFragment,
            int inAnimationId, int outAnimationId) {
        fm.beginTransaction()/*www  .j  av  a  2  s  .  com*/
                .setCustomAnimations(inAnimationId, outAnimationId)
                .hide(hideFragment).show(showFragment)
                .commitAllowingStateLoss();
    }
}

Related Tutorials