private static void changeFragment(Fragment f, boolean init) {
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.info_content, f,f.getClass().getName());
if(!init){
ft.addToBackStack(null);
}
ft.commit();
}
当我想要得到的协议栈通过调用fm.getBackStackEntryCount(COUT),它返回零?
when I want to get the stack cout by call fm.getBackStackEntryCount(), it returns zero?
您得叫 fm.executePendingTransactions()
在 ft.commit ()
或之前 fm.getBackStackEntryCount()
。由于提交()只时间表以后通的交易。
You have to call a fm.executePendingTransactions()
after ft.commit()
or before fm.getBackStackEntryCount()
. Because the commit() only schedules the transactions for a later pass.