Recycler View Not Showing

╄→尐↘猪︶ㄣ 提交于 2019-12-01 02:10:58
Psypher

The issue is that you are returning the item count as 0 which tells that there is no rows to show. You should return the size of the List as shown below.

    @Override
    public int getItemCount() {
        return data.size();
    }

Replace following line

 mRecyclerView.setAdapter(adapter);
 mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

with

mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));    
mRecyclerView.setAdapter(adapter);
Zhivko Dunovski

I agree that you need to return the correct item number but I think you might have a problem with setting the recycler view's height to wrap_content as well. I found this link very helpful. Hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!