本文整理汇总了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);
}