Code example for FragmentTransaction

Methods: addToBackStack, remove, show

0
 
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_about");
        if (prev != null) {
            ft.remove(prev);
        } 
        ft.addToBackStack(null);
 
        new AboutDialog().show(ft,"dialog_about");
    } 
 
    /** 
     * About Dialog 
     */ 
    public static class AboutDialog extends DialogFragment {
 
        private static final String VERSION_UNAVAILABLE = "N/A";
 
        public AboutDialog() { 
        }