What is the equivalent of listview.getCount in case of Recyclerview
//use this method to return recycler adapter item count..
private int recyclerCount(){
int Count = 0;
if (mAdapter != null) {
count = mAdapter.getItemCount();
}
return count;
}
there is no equivalent. The RecyclerView
has no direct knowledge of the underlying dataset. The closest thing is
int count = 0;
if (recyclerViewInstance.getAdapter() != null) {
count = recyclerViewInstance.getAdapter().getItemCount();
}
or if you have a reference to your adapter, simply call
int count = 0;
if (mAdapter != null) {
count = mAdapter.getItemCount();
}