Android关于RecycleView不走onBindViewHolder和onCreateViewHolder问题

在添加适配器的时候,忘记设置条目样式!

添加以下代码既能解决!

RecyclerView.LayoutManager layout=new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);//(垂直布局、水平布局)
参数1:上下文
参数2:水平还是垂直
参数3:为false表示数据按输入的顺序显示,为true表示数据逆向显示。

StaggeredGridLayoutManager layout=new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);//(瀑布流布局)
参数1:为每行几个元素
参数2:为垂直瀑布还是水平瀑布




recyclerView.setLayoutManager(layout);

 

 

    原文作者:codekxx
    原文地址: https://blog.csdn.net/codekxx/article/details/82664445
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞