當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentManager.getBackStackEntryAt方法代碼示例

本文整理匯總了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();
        }
    }
}
 
開發者ID:steelkiwi,項目名稱:NavigationTools,代碼行數:30,代碼來源:NavigationBackManager.java

示例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;
            }
        }
    }
}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:16,代碼來源:QMUIFragment.java

示例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;					
	}

	
}
 
開發者ID:Greenstand,項目名稱:treetracker-android,代碼行數:31,代碼來源:ExitFragment.java


注:本文中的android.support.v4.app.FragmentManager.getBackStackEntryAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。