remove Fragment - Android User Interface

Android examples for User Interface:Fragment

Description

remove Fragment

Demo Code


//package com.java2s;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;

public class Main {
    public static void removeFragment(Fragment fragment,
            FragmentActivity activity) {
        if (fragment != null) {
            FragmentTransaction fragTransaction = activity
                    .getSupportFragmentManager().beginTransaction();
            fragTransaction.remove(fragment);
            fragTransaction.commit();/*from   ww  w . ja  v  a  2 s .c  o  m*/
        }
    }
}

Related Tutorials