I have a RecyclerView getting external JSON data parsed from a server. It works fine however the Volley async task on JSON sometimes takes a while and when it does the fragm
How is described in https://developer.android.com/training/material/lists-cards.html
The overriden method getItemCount() is invoked by the layout manager.
This is the snippet:
// Return the size of your dataset (invoked by the layout manager)
@Override
public int getItemCount() {
return mDataset.length;
}
So to detect if the recyclerView is empty you must request it to your LayoutManager. Example:
if( mLayoutManager.getItemCount() == 0 ){
//Do something
}
I try to getItemCount() of my Adapter but this returns 0, I don't know why it is...