本文主要是介绍在Fragment中使用RecyclerView或XRecyclerView出现 No adapter attached; skipping layout,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在onCreateView中再添加setLayoutManager,setAdapter即可
@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {View view = LayoutInflater.from(getContext()).inflate(R.layout.tab_fragment1, null);unbinder = ButterKnife.bind(this, view);tabfragment1Recycler.setLayoutManager(new LinearLayoutManager(getContext()));//创建适配器tabFragmentReAdapter = new TabFragmentReAdapter(list, getContext());tabfragment1Recycler.setAdapter(tabFragmentReAdapter);return view;}
@Overridepublic void onActivityCreated(@Nullable Bundle savedInstanceState) {super.onActivityCreated(savedInstanceState);tabfragment1Recycler.setLayoutManager(new LinearLayoutManager(getContext()));//创建适配器tabFragmentReAdapter = new TabFragmentReAdapter(list, getContext());tabfragment1Recycler.setAdapter(tabFragmentReAdapter);
这篇关于在Fragment中使用RecyclerView或XRecyclerView出现 No adapter attached; skipping layout的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!