我需要使用单个片段实例管理导航抽屉中的后退按钮句柄。
FragmentManager fManager = getFragmentManager();
FragmentTransaction fTransaction = fManager.beginTransaction();
Fragment fragment = fManager.findFragmentByTag("uniqueTag");
// If fragment doesn't exist yet, create one
if (fragment == null) {
fTransaction.add(R.id.fragment_list, new ListFrag(), "uniqueTag");
}else { // re-use the old fragment
fTransaction.replace(R.id.fragment_list, fragment, "uniqueTag");
}
添加回堆栈时此代码无效。
fTransaction.add(R.id.frame, fragment).addToBackStack("fragback").commit();
任何帮助?