此代码来自我的Fragment1(创建另一个片段)
currentState = currentStateFactory.factory();
Log.e("","new state = "+currentState);
//In the log I can see currentState is not null
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
if (ft != null) {
Log.e("","replacing");
ft.replace(R.id.inner_container, currentState, CURRENT_STATE).commit();
}
currentState = (InitableFragment) getChildFragmentManager().findFragmentByTag(CURRENT_STATE);
Log.e("", "currentState != null check... "+currentState);
//In the log I can see currentState is null
if (currentState != null) {
Log.e("", "currentState initng");
currentState.init();
}
为什么findFragmentByTag返回null?
答案 0 :(得分:0)
根据Android开发人员参考:
计划此交易的提交。提交不会立即发生;它将被安排为主线程上的工作,以便在下一次线程就绪时完成。
http://developer.android.com/reference/android/app/FragmentTransaction.html#commit()
也许您可以将0x41 0x00 -> U+0041
0x42 0x00 -> U+0042
0x43 0x00 -> U+0043
0x00 0x00 -> U+0000
电话移动到您的片段#init()
中?