Recycler View Not Showing

后端 未结 4 525
死守一世寂寞
死守一世寂寞 2020-12-10 10:49

I have been making an app that uses a recycler view in a navigation drawer how the contents of the recycler view have not been showing up. The view is definitely their as I

相关标签:
4条回答
  • 2020-12-10 10:54

    Make sure RecyclerView parent container width not set as WrapContent

    0 讨论(0)
  • 2020-12-10 10:55

    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.

    0 讨论(0)
  • 2020-12-10 11:03

    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();
        }
    
    0 讨论(0)
  • 2020-12-10 11:13

    Replace following line

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

    with

    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));    
    mRecyclerView.setAdapter(adapter);
    
    0 讨论(0)
提交回复
热议问题