美文网首页
recycler view 报空指针错误

recycler view 报空指针错误

作者: NNNie | 来源:发表于2018-03-31 19:16 被阅读0次

    程序在setLayoutManager的时候crash,debug之后发现初始化recyclerview的时候findViewById失败了,最后发现是因为inflate方法里的layout名字写错了。。。

    View view = inflater.inflate(R.layout.news_title_frag, container,false); 找到对应layout,然后RecyclerView newsTitleRecyclerView = (RecyclerView) view.findViewById(R.id.news_title_recycler_view); layout写错导致没找到id。

    相关文章

      网友评论

          本文标题:recycler view 报空指针错误

          本文链接:https://www.haomeiwen.com/subject/uxkncftx.html