Java Code Examples for android.app.FragmentTransaction#attach()

The following examples show how to use android.app.FragmentTransaction#attach() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FragmentTabHost.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
private FragmentTransaction doTabChanged(String tabId, FragmentTransaction ft) {
    TabInfo newTab = null;
    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;
}
 
Example 2
Source File: TabListener.java    From adapter-kit with Apache License 2.0 5 votes vote down vote up
public void onTabSelected(Tab tab, FragmentTransaction ft) {
	// Check if the fragment is already initialized
	if (mFragment == null) {
		// If not, instantiate and add it to the activity
		mFragment = Fragment.instantiate(mActivity, mClass.getName());
		ft.add(android.R.id.content, mFragment, mTag);
	} else {
		// If it exists, simply attach it in order to show it
		ft.attach(mFragment);
	}
}
 
Example 3
Source File: FragmentTabs.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    if (mFragment == null) {
        mFragment = Fragment.instantiate(mActivity, mClass.getName(), mArgs);
        ft.add(android.R.id.content, mFragment, mTag);
    } else {
        ft.attach(mFragment);
    }
}
 
Example 4
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onTabSelected(Tab tab, FragmentTransaction ft) {
	// Check if the fragment is already initialized
	if (mFragment == null) {
		// If not, instantiate and add it to the activity
		mFragment = Fragment.instantiate(mActivity, mClass.getName());
		ft.add(android.R.id.content, mFragment, mTag);
	} else {
		// If it exists, simply attach it in order to show it
		ft.setCustomAnimations(android.R.animator.fade_in,
				R.animator.animationtest);
		ft.attach(mFragment);
	}
}
 
Example 5
Source File: ArrayPagerAdapter.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void attach(Fragment fragment,
                   FragmentTransaction currTransaction) {
    currTransaction.attach(fragment);
}
 
Example 6
Source File: FragmentTabHost.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
private FragmentTransaction a(String s, FragmentTransaction fragmenttransaction)
{
    j j1 = null;
    int i = 0;
    while (i < a.size()) 
    {
        j j2 = (j)a.get(i);
        if (!j.b(j2).equals(s))
        {
            j2 = j1;
        }
        i++;
        j1 = j2;
    }
    if (j1 == null)
    {
        throw new IllegalStateException((new StringBuilder()).append("No tab known for tag ").append(s).toString());
    }
    if (g != j1)
    {
        if (fragmenttransaction == null)
        {
            fragmenttransaction = d.beginTransaction();
        }
        if (g != null && j.a(g) != null)
        {
            fragmenttransaction.detach(j.a(g));
        }
        if (j1 != null)
        {
            if (j.a(j1) == null)
            {
                j.a(j1, Fragment.instantiate(c, j.c(j1).getName(), j.d(j1)));
                fragmenttransaction.add(e, j.a(j1), j.b(j1));
            } else
            {
                fragmenttransaction.attach(j.a(j1));
            }
        }
        g = j1;
    }
    return fragmenttransaction;
}
 
Example 7
Source File: ArrayPagerAdapter.java    From cwac-pager with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void attach(Fragment fragment,
                   FragmentTransaction currTransaction) {
  currTransaction.attach(fragment);
}