My RecyclerView
does not call onCreateViewHolder
, onBindViewHolder
even MenuViewHolder
constructor, therefore nothing app
I had the same problem, because I was using android.support.constraint.ConstraintLayout
in layout resource.
Changing to FrameLayout
helped.
I really really hope this helps someone someday. I just spend over an hour on this one going nuts!
I had this:
projects_recycler_view.apply {
this.layoutManager = linearLayoutManager
this.adapter = adapter
}
When I should have had this:
projects_recycler_view.apply {
this.layoutManager = linearLayoutManager
this.adapter = projectAdapter
}
Because I foolishly called my adapter adapter
, it was being shadowed by the recycler view's adapter in the apply block! I renamed the adapter to projectAdapter to differentiate it and problem solved!
Setting the height of the TextView
in the custom.xml
or RecyclerView
. If height is wrap-content
, the RecyclerView
will not be visible.
This happened when my RecyclerView
was inside a ScrollView
and I was using Android Support Library 23.0. To fix, I updated to Android Support Library 23.2:
In build.gradle:
dependencies {
...
compile 'com.android.support:appcompat-v7:23.2.+'
compile 'com.android.support:cardview-v7:23.2.+'
}
I struggled with this issue for many hours. I was using a fragment. And the issue was not returning the view
. Below is my code:
ProductGridBinding binding = DataBindingUtil.inflate( inflater, R.layout.product_grid, container, false);
mLinearLayoutManager = new LinearLayoutManager(getActivity());
mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
binding.rvNumbers.setHasFixedSize(true);
binding.rvNumbers.setLayoutManager(mLinearLayoutManager);
binding.rvNumbers.setAdapter(adapter);
View view = binding.getRoot();
return view;
In my case , I was missing calling notifyDataSetChanged()
after setting list in adapter.
public void setUserList(List<UserList> userList) {
this.userList = userList;
notifyDataSetChanged();
}