How To Know When Data Is Loaded Inside Custom Recyclerview?
I am create and using custom RecyclerView in my application. I need to call getChildAt(0).getWidth() before any working to save first item width in class field. For that I need to
Solution 1:
RecyclerView is already calling registerAdapterDataObserver
and it's unregister counterpart on the adapter the supplied adapter.
This observer have several callbacks to let the Recycler know when data is added, removed or changed. You should take advantage of those.
Also, the moment the adapter changes the data, it's not the same moment the views are created/layout on the screen. You might have to call getViewTreeObserver().addOnGlobalLayoutListener
to receive a callback when the children have been layout on the screen.
Hope it helps, happy coding.
Post a Comment for "How To Know When Data Is Loaded Inside Custom Recyclerview?"