本文整理匯總了Java中android.support.v4.app.FragmentManager.getBackStackEntryAt方法的典型用法代碼示例。如果您正苦於以下問題:Java FragmentManager.getBackStackEntryAt方法的具體用法?Java FragmentManager.getBackStackEntryAt怎麽用?Java FragmentManager.getBackStackEntryAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.FragmentManager
的用法示例。
在下文中一共展示了FragmentManager.getBackStackEntryAt方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: navigateBack
import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
public void navigateBack() {
activity.hideKeyboard();
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager.getBackStackEntryCount() > 0) {
Log.i(TAG, "Popping back stack");
int fragmentPosition = fragmentManager.getBackStackEntryCount() - 1;
FragmentManager.BackStackEntry backEntry = fragmentManager.getBackStackEntryAt(fragmentPosition);
String fragmentName = backEntry.getName();
fragmentManager.popBackStackImmediate(fragmentName, FragmentManager.POP_BACK_STACK_INCLUSIVE);
navigationManager.removeFragmentsFromStack(fragmentPosition);
} else {
Log.i(TAG, "Nothing on back stack");
if (activity.isTaskRoot()) {
if (doublePressToExit) {
activity.finish();
return;
}
doublePressToExit = true;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
doublePressToExit = false;
}
}, TIME_INTERVAL);
} else {
activity.finish();
}
}
}
示例2: onCreate
import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
int backStackEntryCount = fragmentManager.getBackStackEntryCount();
for (int i = backStackEntryCount - 1; i >= 0; i--) {
FragmentManager.BackStackEntry entry = fragmentManager.getBackStackEntryAt(i);
if (getClass().getSimpleName().equals(entry.getName())) {
mBackStackIndex = i;
break;
}
}
}
}
示例3: onClick
import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
public void onClick(View v) {
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
switch (v.getId()) {
case R.id.fragment_exit_yes:
MainActivity.syncDataFromExitScreen = true;
fragment = new DataFragment();
bundle = getActivity().getIntent().getExtras();
fragment.setArguments(bundle);
fragmentTransaction = getActivity().getSupportFragmentManager()
.beginTransaction();
fragmentTransaction.replace(R.id.container_fragment, fragment).addToBackStack(ValueHelper.DATA_FRAGMENT).commit();
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentManager.BackStackEntry first = manager.getBackStackEntryAt(0);
manager.popBackStack(first.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
break;
case R.id.fragment_exit_no:
getActivity().finish();
break;
}
}