Recyclerview not call onCreateViewHolder

前端 未结 30 1478
离开以前
离开以前 2020-11-28 07:04

My RecyclerView does not call onCreateViewHolder, onBindViewHolder even MenuViewHolder constructor, therefore nothing app

30条回答
  •  盖世英雄少女心
    2020-11-28 08:01

    In my case, my list size was 0 and it was not calling the onCreateViewHolder method. I needed to display a message at center for the empty list as a placeholder so I did it like this and it worked like charm. Answer by @Konstantin Burov helped.

      @Override
    public int getItemCount() {
        if (contactList.size() == 0) {
            return 1;
        } else {
            return contactList.size();
        }
    }
    

提交回复
热议问题