FragmentManager beginTransaction - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for FragmentManager beginTransaction method.

This code example shows how to use the following methods:beginTransaction, findFragmentByTag
     * @param tag 
     */ 
    protected static void show(DialogFragmentActivity activity,
            DialogFragmentHelper fragment, Bundle arguments, String tag) {
        FragmentManager manager = activity.getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        Fragment current = manager.findFragmentByTag(tag);
        if (current != null)
            transaction.remove(current);
        transaction.addToBackStack(null);
 
        fragment.setArguments(arguments);
        fragment.show(manager, tag);
    } 
 
    /** 
     * Create bundle with standard arguments 
     * 
     * @param title 
     * @param message 
9
CodeRank
This code example shows how to use the following methods:show, beginTransaction, findFragmentByTag
This code example shows how to use the following methods:show, beginTransaction, findFragmentByTag
            return this;
        } 
 
        public void show() { 
            FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
 
            Fragment prev = fragmentManager.findFragmentByTag(FRAGMENT_TAG);
            if (prev != null) {
                fragmentTransaction.remove(prev);
            } 
            fragmentTransaction.addToBackStack(null);
 
            ProgressDialogFragment.newInstance(mMessage, mOnCancelListener, mCancelable)
                    .show(fragmentManager, FRAGMENT_TAG);
        } 
    } 
 
    public static void dismiss(FragmentActivity activity) {
        FragmentManager fragmentManager = activity.getSupportFragmentManager();
7
CodeRank
This code example shows how to use the following methods:show, beginTransaction, findFragmentByTag
            return this;
        } 
 
        public void show() { 
            FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
 
            Fragment prev = fragmentManager.findFragmentByTag(FRAGMENT_TAG);
            if (prev != null) {
                fragmentTransaction.remove(prev);
            } 
            fragmentTransaction.addToBackStack(null);
 
            ErrorDialogFragment.newInstance(mTitle, mMessage, mOnClickListener, mOnCancelListener)
                    .show(fragmentManager, FRAGMENT_TAG);
        } 
    } 
 
    public static void dismiss(FragmentActivity activity) {
        FragmentManager fragmentManager = activity.getSupportFragmentManager();
7
CodeRank
This code example shows how to use the following methods:show, beginTransaction, findFragmentByTag
This code example shows how to use the following methods:beginTransaction, findFragmentByTag
            super.onActivityCreated(savedInstanceState);
 
            FragmentManager fm = getFragmentManager();
 
            // Check to see if we have retained the worker fragment. 
            mWorkFragment = (RetainedFragment)fm.findFragmentByTag("work");
 
            // If not retained (or first time running), we need to create it. 
            if (mWorkFragment == null) {
                mWorkFragment = new RetainedFragment();
                // Tell it who it is working with. 
                mWorkFragment.setTargetFragment(this, 0);
                fm.beginTransaction().add(mWorkFragment, "work").commit();
            } 
        } 
 
    } 
 
    /** 
     * This is the Fragment implementation that will be retained across 
7
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentByTag
public class Utils { 
 
    public static void showAbout(Activity activity) {
 
        FragmentManager fm = activity.getFragmentManager();
        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 {
 
7
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentByTag
    } 
 
    @Override 
    public Object instantiateItem(ViewGroup container, int position) {
        if (mCurTransaction == null) {
            mCurTransaction = mFragmentManager.beginTransaction();
        } 
 
        final long itemId = getItemId(position);
 
        // Do we already have this fragment? 
//        String name = makeFragmentName(container.getId(), itemId); 
        String name = getTag(position);
        Fragment fragment = mFragmentManager.findFragmentByTag(name);
        if (fragment != null) {
            if (DEBUG) Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment);
            mCurTransaction.attach(fragment);
        } else { 
            fragment = getItem(position);
            if (DEBUG) Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
7
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentByTag
This code example shows how to use the following methods:beginTransaction, findFragmentByTag
beginTransaction Method Overview
Start a series of edit operations on the Fragments associated with this FragmentManager.
See Code Examples for other Android FragmentManager Methods: