Code example for FragmentTransaction

Methods: addToBackStackcommitreplace

0
package com.example.fragmenttest; 
 
import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentManager; 
import android.support.v4.app.FragmentTransaction; 
 
public class Utils { 
	public static void pushFragment(FragmentManager fm, int parentId, Fragment currentFrag, Fragment newFrag,String tag) {
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(parentId, newFrag, tag);
        /*ft.add(parentId, newFrag, tag); 
        if(currentFrag!=null){ 
        	ft.hide(currentFrag); 
        } 
        ft.show(newFrag);*/ 
        ft.addToBackStack(null);
        ft.commit();
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE