Reputation: 13
I've created a library that allows user to download images in background and put it in a View, passed by argument to a function, when download is finished. The problem is that if I use my library in a listview, calling this method in the getView() method, when a user scroll very fast, the library do a request for each row passed. But I'd like to do it, only when a cell is really visible by user... maybe when the scroll list is stopped. So, how can I check this thing on the single view that I pass to the library method? Thaaanks
Upvotes: 1
Views: 4800
Reputation: 75798
You can use
getVisibility () Returns the visibility status for this view .
isShown () Returns the visibility of this view and all of its ancestors .
if (ViewObj.getVisibility() == View.VISIBLE) {
// Your Staff
} else {
// Your Staff
}
True if this view and all of its ancestors are VISIBLE
Upvotes: 4
Reputation: 1150
You can use view.getVisibility()
. The result will be View.VISIBLE
, View.GONE
or View.INVISIBLE
.
If you want to do something when your view is visible, then your expected result will be: View.VISIBLE
if(yourView.getVisibility() == View.VISIBLE){
//Do what you want..
}
Upvotes: 0