本文整理匯總了Java中android.app.FragmentManager.getBackStackEntryAt方法的典型用法代碼示例。如果您正苦於以下問題:Java FragmentManager.getBackStackEntryAt方法的具體用法?Java FragmentManager.getBackStackEntryAt怎麽用?Java FragmentManager.getBackStackEntryAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.FragmentManager
的用法示例。
在下文中一共展示了FragmentManager.getBackStackEntryAt方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
}
}