我在这里使用的是android TV leanback示例, https://github.com/googlesamples/androidtv-Leanback
当我尝试像这样替换MainFragment
中的片段时
getFragmentManager().beginTransaction().replace(R.id.main_frame, SampleFragment)
.addToBackStack(null).commit();
它崩溃
android.support.v7.widget.RecyclerView $ ViewHolder.shouldIgnore()”位于 空对象引用 在android.support.v7.widget.RecyclerView.findMinMaxChildLayoutPositions(RecyclerView.java:3989)
即使我替换为空白片段,它也会发生
答案 0 :(得分:0)
Please follow the following pattern and it should help you resolve the issue. I had the same exact issue and took me awhile to figure it out finally.
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.replace(R.id.fragment_container, destinationFragment, null);
ft.commit();
Note: No need to add ".addToBackStack(null)"