I extended
RecyclerView.Adapter<RecyclerView.ViewHolder>
And when I called:
mRecyclerView.getAdapter().notifyDataSetChanged();
Nothing happened.
The only way to refresh the view is to set again the adapter (see this answer):
mRecyclerView.setAdapter(new MyAdapter(...));
I have two issues with this solution:
Any ideas?
If notifyDataSetChanged()
does not trigger view updates than there is a chance that you have forgotten to call SetLayoutManager()
on your RecyclerView (like I did!).
Just don't forget to do this:
Java code:
LinearLayoutManager layoutManager = new LinearLayoutManager(context ,LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager)
C# code, I'm using Xamarin.
var layoutManager = new LinearLayoutManager(Context, LinearLayoutManager.Vertical, false);
recyclerView.SetLayoutManager(layoutManager);
before you call recyclerView.SetAdapter(adapter)
;