13

I have a adapter which populates data to RecyclerView.

I am not calling notifyDataSetChanged() and I am setting the adapter to the RecyclerView in onCreateView() (so in getItemCount() should be called once) in Fragment but I find getItemCount() called multiple times.

Sufian
  • 6,405
  • 16
  • 66
  • 120
Preethi
  • 2,112
  • 7
  • 38
  • 54
  • 18
    "when does getItemCount() method get called in RecycleView adapter?" -- whenever the `RecyclerView` wants. You should not be making any assumptions about how many times `getItemCount()` will be called. Focus on ensuring that `getItemCount()` is fast, and the number of times that it is called will not matter. – CommonsWare Jul 31 '15 at 14:06

0 Answers0