Example usage for android.app FragmentTransaction attach

List of usage examples for android.app FragmentTransaction attach

Introduction

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

Prototype

public abstract FragmentTransaction attach(Fragment fragment);

Source Link

Document

Re-attach a fragment after it had previously been detached from the UI with #detach(Fragment) .

Usage

From source file:es.farfuteam.vncpp.controller.TabListener.java

/**
 * @param tab//from ww w  . ja  v  a  2s .c om
 * @param ft
 * @brief Method called when the tab is selected
 * @details Method called when the tab is selected
 */
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    // Check if the fragment is already initialized
    mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag);
    mActivity.getSupportFragmentManager().findFragmentByTag(mTag);
    if (mFragment == null) {
        // If not, instantiate and add it to the activity
        mFragment = Fragment.instantiate(mActivity, mClass.getName());
        //mFragment.setProviderId(mTag); // id for event provider
        setmTransaction(ft);
        ft.add(android.R.id.content, mFragment, mTag);
    } else {
        // If it exists, simply attach it in order to show it
        setmTransaction(ft);
        ft.attach(mFragment);
    }

}

From source file:it.angrydroids.epub3reader.MainActivity.java

public void attachPanel(SplitPanel p) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.attach(p);
    fragmentTransaction.commit();/*from  w  w  w.  j a  v a2 s  . c o  m*/

    panelCount++;
}

From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java

/**
 * Re-attach a panel that has been detached previously.
 *//*from  w w w  . ja  v a 2s.c  om*/
public void attachPanel(SplitPanel p) {
    Log.d(LOG, "ReaderActivity.attachPanel");

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.attach(p);
    fragmentTransaction.commit();

    panelCount++;
}

From source file:android.support.v13.app.FragmentTabHost.java

private FragmentTransaction doTabChanged(String tabId, FragmentTransaction ft) {
    TabInfo newTab = null;/* w w  w  .  j  a v  a  2  s  .  com*/
    for (int i = 0; i < mTabs.size(); i++) {
        TabInfo tab = mTabs.get(i);
        if (tab.tag.equals(tabId)) {
            newTab = tab;
        }
    }
    if (newTab == null) {
        throw new IllegalStateException("No tab known for tag " + tabId);
    }
    if (mLastTab != newTab) {
        if (ft == null) {
            ft = mFragmentManager.beginTransaction();
        }
        if (mLastTab != null) {
            if (mLastTab.fragment != null) {
                ft.detach(mLastTab.fragment);
            }
        }
        if (newTab != null) {
            if (newTab.fragment == null) {
                newTab.fragment = Fragment.instantiate(mContext, newTab.clss.getName(), newTab.args);
                ft.add(mContainerId, newTab.fragment, newTab.tag);
            } else {
                ft.attach(newTab.fragment);
            }
        }

        mLastTab = newTab;
    }
    return ft;
}