Recyclerview not call any Adapter method :onCreateViewHolder,onBindViewHolder,

前端 未结 8 1861
灰色年华
灰色年华 2020-12-01 08:54

my RecyclerView do not call onCreateViewHolder, onBindViewHolder, therefore, does not appear nothing in recyclerview. I put logs for debugging, and no log is shown. What can

8条回答
  •  渐次进展
    2020-12-01 09:28

    Its late but hope it will help somone. try either of the following:

    first solution: make sure you haven't use this line unnecessarily

    recyclerView.setHasFixedSize(true);
    

    second solution: make sure you set layout manager to recyclerView

    recycler.setLayoutManager(new LinearLayoutManager(this));
    

    third solution: you getItemCount returns 0, So RecyclerView never tries to instantiate a view. Make it return something greater than 0

提交回复
热议问题