Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grid view get items which are visible to user

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?

like image 288
aditimirani Avatar asked Nov 03 '11 09:11

aditimirani


1 Answers

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
}
like image 100
teoREtik Avatar answered Oct 07 '22 12:10

teoREtik