当前位置: 首页>>代码示例>>Java>>正文


Java FragmentManager.popBackStackImmediate方法代码示例

本文整理汇总了Java中android.app.FragmentManager.popBackStackImmediate方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentManager.popBackStackImmediate方法的具体用法?Java FragmentManager.popBackStackImmediate怎么用?Java FragmentManager.popBackStackImmediate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.FragmentManager的用法示例。


在下文中一共展示了FragmentManager.popBackStackImmediate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: changeFragment

import android.app.FragmentManager; //导入方法依赖的package包/类
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
	FragmentManager fm = getFragmentManager();
	FragmentTransaction transaction = fm.beginTransaction();

	/*if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
		if (newFragmentType.isRightOf(currentFragment)) {
			transaction.setCustomAnimations(R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left,
					R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right);
		} else {
			transaction.setCustomAnimations(R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right,
					R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left);
		}
	}*/

	if (newFragmentType != FragmentsAvailable.DIALER
			&& newFragmentType != FragmentsAvailable.CONTACTS_LIST
			&& newFragmentType != FragmentsAvailable.CHAT_LIST
			&& newFragmentType != FragmentsAvailable.HISTORY_LIST) {
		transaction.addToBackStack(newFragmentType.toString());
	} else {
		while (fm.getBackStackEntryCount() > 0) {
			fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
		}
	}

	transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
	transaction.commitAllowingStateLoss();
	fm.executePendingTransactions();

	currentFragment = newFragmentType;
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:36,代码来源:LinphoneActivity.java

示例2: onBackPressed

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    if (isSearchViewExpanded()) {
        hideSearchView();
    } else {
        final FragmentManager fm = getFragmentManager();
        mBackStackEntryPopped = fm.popBackStackImmediate();
        final int entryCnt = fm.getBackStackEntryCount();

        if (entryCnt > 0) {
            final FragmentManager.BackStackEntry entry = fm.getBackStackEntryAt(entryCnt - 1);
            final Fragment fragment = fm.findFragmentByTag(entry.getName());

            if (fragment instanceof CurrentFeedFragment) {
                mBottomNavigationView.setSelectedItemId(R.id.action_view_current_feed);
            } else if (fragment instanceof FeedSubscriptionsFragment) {
                mBottomNavigationView.setSelectedItemId(R.id.action_view_feed_subscriptions);
            } else if (fragment instanceof SavedEntriesFragment) {
                mBottomNavigationView.setSelectedItemId(R.id.action_view_saved_entries);
            } else {
                mBackStackEntryPopped = fm.popBackStackImmediate();
                mBottomNavigationView.setSelectedItemId(R.id.action_view_feed_subscriptions);
            }

            mBackStackEntryPopped = false;
        } else {
            super.onBackPressed();
        }
    }
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:31,代码来源:MainActivity.java

示例3: clearBackStack

import android.app.FragmentManager; //导入方法依赖的package包/类
private void clearBackStack(FragmentManager fragmentManager ){
    while (fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStackImmediate();
    }
}
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:6,代码来源:MainActivity.java


注:本文中的android.app.FragmentManager.popBackStackImmediate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。