Android recyclerview: callback view when fully visible

This is a use case:

I have a recyclerview list of 5 food imageviews:

>Watermelon > mango > peach > Apple > guava

I want to record an output (log. E (tag, "peaches are displayed!"), and when the user scrolls through it, the peaches image view is fully visible in the recyclerview

When the view is fully visible in recyclerview, is there a callback called? I almost want to convert the method findfirstcompletelyvisibleitemposition() to a callback method: http://developer.android.com/reference/android/support/v7/widget/LinearLayoutManager.html#findFirstCompletelyVisibleItemPosition ()

I read this thread: recyclerview – callback when view is no longer visible, and then view the document here http://developer.android.com/reference/android/support/v7/widget/RecyclerView.OnChildAttachStateChangeListener.html , but I see that the callback method onchildviewattachedtowindow() is called in the following cases:

Attachments can be attached before the view is actually displayed

I can think of an extremely inefficient method:

>Set recyclerview. Onscrolllistener on your recyclerview > call mlinearlayoutmanager. Findfirstcompletelyvisibleitemposition() within the onscrolled method. Check that the return is int equal to 3

Each time the recyclerview scrolls, hundreds of calculations will be performed

resolvent:

As you mentioned, you should actually handle it in the onscroled () method. The findfirstcompletelyvisibleitemposition () method is very effective, and the calculation will not affect most devices, including low-end devices

Incidentally, I think what you want is the findlastcompletelyvisibleitemposition () method

Yes, I have: -)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>