Example usage for android.app FragmentTransaction add

List of usage examples for android.app FragmentTransaction add

Introduction

In this page you can find the example usage for android.app FragmentTransaction add.

Prototype

public abstract FragmentTransaction add(@IdRes int containerViewId, Fragment fragment);

Source Link

Document

Calls #add(int,Fragment,String) with a null tag.

Usage

From source file:com.bernard.beaconportal.activities.activity.MessageList.java

private void initializeFragments() {
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.addOnBackStackChangedListener(this);

    boolean hasMessageListFragment = (mMessageListFragment != null);

    if (!hasMessageListFragment) {
        FragmentTransaction ft = fragmentManager.beginTransaction();
        mMessageListFragment = MessageListFragment.newInstance(mSearch, false,
                (K9.isThreadedViewEnabled() && !mNoThreading));
        ft.add(R.id.message_list_container, mMessageListFragment);
        ft.commit();/*from  w ww .  j ava  2 s  . c o m*/
    }

    // Check if the fragment wasn't restarted and has a MessageReference in
    // the arguments. If
    // so, open the referenced message.
    if (!hasMessageListFragment && mMessageViewFragment == null && mMessageReference != null) {
        openMessage(mMessageReference);
    }
}