Recyclerview Not Calling Oncreateviewholder or Onbindview

Recyclerview not call onCreateViewHolder

Your getItemCount method returns 0. So RecyclerView never tries to instantiate a view. Make it return something greater than 0.

for example

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

FirestoreRecyclerAdapter not calling onCreateViewHolder

RecylerView Adapter onCreateViewHolder & onBindViewHolder not called: view empty

Try setting the adapter to the RecyclerView earlier on the lifecycle (onCreate is a good choice), and when your AsyncTask is done only notify the adapter via notifyDataSetChanged()

Also, make sure you set a LayoutManager, like this:

recycler.setLayoutManager(new LinearLayoutManager(this));

Since your RecyclerView lives inside the fragment, in your case will be:

recycler.setLayoutManager(new LinearLayoutManager(getActivity()));

Regarding your question

I'm also curious as to what actually triggers the calling of these two
methods on the adapter... if I can figure that out, maybe I can
determine why the event isn't being triggered.

it has to do mostly with your dataset size when the time to render the list arrives. In your case (and once mine), missing to set the LayoutManager, somehow, causes not to render either.

You already have a reference to the context in your adapter, can you try to do:

@Override
public RecyclerViewAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(context).inflate(R.layout.todays_visit_list_item, parent, false); //
RecyclerViewAdapter.MyViewHolder holder = new RecyclerViewAdapter.MyViewHolder(v);
return holder;
}

Recycler adapter doesn't call onCreateViewHolder

The problem was in root layout of activity. It was android.support.constraint.ConstraintLayout. In combination with parameter layout_height"match_parent" of container of fragment it's give that problem. If change ConstraintLayout to any other - it will work properly.



Related Topics



Leave a reply



Submit