本文整理匯總了Java中android.app.FragmentTransaction.attach方法的典型用法代碼示例。如果您正苦於以下問題:Java FragmentTransaction.attach方法的具體用法?Java FragmentTransaction.attach怎麽用?Java FragmentTransaction.attach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.FragmentTransaction
的用法示例。
在下文中一共展示了FragmentTransaction.attach方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTabSelected
import android.app.FragmentTransaction; //導入方法依賴的package包/類
/**
* @brief Method called when the tab is selected
* @param tab
* @param ft
* @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);
}
}
示例2: reloadFragment
import android.app.FragmentTransaction; //導入方法依賴的package包/類
public static void reloadFragment(FragmentManager fragmentManager, Fragment fragment, int containViewId) {
if (fragment != null){
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.setTransition(-1);
// ft.replace(containViewId, fragment);
ft.detach(fragment);
ft.attach(fragment);
ft.commitAllowingStateLoss();
}
}
示例3: attach
import android.app.FragmentTransaction; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void attach(Fragment fragment,
FragmentTransaction currTransaction) {
currTransaction.attach(fragment);
}