本文整理了Java中android.app.FragmentTransaction.detach()
方法的一些代码示例,展示了FragmentTransaction.detach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FragmentTransaction.detach()
方法的具体详情如下:
包路径:android.app.FragmentTransaction
类名称:FragmentTransaction
方法名:detach
暂无
代码示例来源:origin: Cleveroad/SlidingTutorial-Android
@SuppressLint("CommitTransaction")
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
}
if (DEBUG) Log.v(TAG, "Detaching item #" + getItemId(position) + ": f=" + object
+ " v=" + ((Fragment) object).getView());
mCurTransaction.detach((Fragment) object);
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
private void helpTestCanGetRequestManagerFromDetachedFragment() {
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
android.app.Fragment fragment = new android.app.Fragment();
activity.getFragmentManager().beginTransaction().add(fragment, PARENT_TAG).detach(fragment)
.commit();
activity.getFragmentManager().executePendingTransactions();
assertTrue(fragment.isDetached());
retriever.get(fragment);
}
代码示例来源:origin: li2/learning-android-open-source
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null) {
ft.detach(mFragment);
}
}
代码示例来源:origin: li2/learning-android-open-source
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null) {
ft.detach(mFragment);
}
}
代码示例来源:origin: qiubiteme/android_api_demos
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null) {
ft.detach(mFragment);
}
}
代码示例来源:origin: qiubiteme/android_api_demos
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null) {
ft.detach(mFragment);
}
}
代码示例来源:origin: apsun/NekoSMS
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
}
mCurTransaction.detach((Fragment)object);
}
代码示例来源:origin: com.albedinsky.android/pager-adapters-core
/**
*/
@Override
@SuppressLint("CommitTransaction")
public void destroyItem(ViewGroup container, int position, Object object) {
if (mPendingTransaction == null) {
// Will be committed in call to finishUpdate(...).
this.mPendingTransaction = mFragmentManager.beginTransaction();
}
if (PagerAdaptersConfig.DEBUG_LOG_ENABLED) {
Log.v(TAG, "Detaching item(id: " + getItemId(position) + ", fragment: " + object + ", view: " + ((Fragment) object).getView() + ").");
}
mPendingTransaction.detach((Fragment) object);
}
代码示例来源:origin: com.albedinsky.android/pager-adapters
/**
*/
@Override
@SuppressLint("CommitTransaction")
public void destroyItem(ViewGroup container, int position, Object object) {
if (mPendingTransaction == null) {
// Will be committed in call to finishUpdate(...).
this.mPendingTransaction = mFragmentManager.beginTransaction();
}
if (PagerAdaptersConfig.DEBUG_LOG_ENABLED) {
Log.v(TAG, "Detaching item(id: " + getItemId(position) + ", fragment: " + object + ", view: " + ((Fragment) object).getView() + ").");
}
mPendingTransaction.detach((Fragment) object);
}
代码示例来源:origin: li2/learning-android-open-source
ft.detach(mLastTab.fragment);
代码示例来源:origin: qiubiteme/android_api_demos
ft.detach(mLastTab.fragment);
代码示例来源:origin: li2/learning-android-open-source
public TabListener(Activity activity, String tag, Class<T> clz, Bundle args) {
mActivity = activity;
mTag = tag;
mClass = clz;
mArgs = args;
// Check to see if we already have a fragment for this tab, probably
// from a previously saved state. If so, deactivate it, because our
// initial state is that a tab isn't shown.
mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag);
if (mFragment != null && !mFragment.isDetached()) {
FragmentTransaction ft = mActivity.getFragmentManager().beginTransaction();
ft.detach(mFragment);
ft.commit();
}
}
代码示例来源:origin: qiubiteme/android_api_demos
public TabListener(Activity activity, String tag, Class<T> clz, Bundle args) {
mActivity = activity;
mTag = tag;
mClass = clz;
mArgs = args;
// Check to see if we already have a fragment for this tab, probably
// from a previously saved state. If so, deactivate it, because our
// initial state is that a tab isn't shown.
mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag);
if (mFragment != null && !mFragment.isDetached()) {
FragmentTransaction ft = mActivity.getFragmentManager().beginTransaction();
ft.detach(mFragment);
ft.commit();
}
}
代码示例来源:origin: qiubiteme/android_api_demos
public TabListener(Activity activity, String tag, Class<T> clz, Bundle args) {
mActivity = activity;
mTag = tag;
mClass = clz;
mArgs = args;
// Check to see if we already have a fragment for this tab, probably
// from a previously saved state. If so, deactivate it, because our
// initial state is that a tab isn't shown.
mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag);
if (mFragment != null && !mFragment.isDetached()) {
FragmentTransaction ft = mActivity.getFragmentManager().beginTransaction();
ft.detach(mFragment);
ft.commit();
}
}
代码示例来源:origin: li2/learning-android-open-source
public TabListener(Activity activity, String tag, Class<T> clz, Bundle args) {
mActivity = activity;
mTag = tag;
mClass = clz;
mArgs = args;
// Check to see if we already have a fragment for this tab, probably
// from a previously saved state. If so, deactivate it, because our
// initial state is that a tab isn't shown.
mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag);
if (mFragment != null && !mFragment.isDetached()) {
FragmentTransaction ft = mActivity.getFragmentManager().beginTransaction();
ft.detach(mFragment);
ft.commit();
}
}
代码示例来源:origin: li2/learning-android-open-source
ft = mManager.beginTransaction();
ft.detach(tab.fragment);
代码示例来源:origin: qiubiteme/android_api_demos
ft = mManager.beginTransaction();
ft.detach(tab.fragment);
代码示例来源:origin: braintree/braintree_android
@Test
public void startActivityForResult_postsExceptionWhenNotAttached() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
mActivity.getFragmentManager().beginTransaction().detach(fragment).commit();
mActivity.getFragmentManager().executePendingTransactions();
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertEquals("BraintreeFragment is not attached to an Activity. Please ensure it is attached and try again.",
error.getMessage());
mCalled.set(true);
}
});
fragment.startActivityForResult(new Intent(), 1);
assertTrue(mCalled.get());
}
代码示例来源:origin: braintree/braintree_android
@Test
public void waitForConfiguration_doesNotPostCallbackWhenNotAttached() throws JSONException,
InvalidArgumentException {
final Configuration configuration = Configuration.fromJson(stringFromFixture("configuration/configuration.json"));
mockConfigurationManager(configuration);
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
mActivity.getFragmentManager().beginTransaction().detach(fragment).commit();
mActivity.getFragmentManager().executePendingTransactions();
fragment.waitForConfiguration(new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration returnedConfiguration) {
fail("onConfigurationFetched was called");
}
});
}
内容来源于网络,如有侵权,请联系作者删除!