I am showing images in a grid view [around 100 images] and those images will refresh after 10 second .i want to refresh only those images which are visible to user.how can i get only visible items from grid view so i can request server to fetch only those images which are visible to user?
for(int i = 0; i < GridView.getChildCount(); i++) {
if(GridView.getChildAt(i).isVisible())
// do what you need
}
You should consider that this is abstract code snippet, just illustrated approach to resolve your problem
Edit: The better way in my opinion:
for(int visiblePosition = GridView.getFirstVisiblePosition(); visiblePosition <= GridView.getLastVisiblePosition(); visiblePosition++) {
View view = GridView.getChildAt(visiblePosition);
// make something
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With