问题
I want to use getLastVisiblePosition() and apparently it is not giving me the right number after this method (notifyDataSetChanged) has been called. I think this method only notifies the view that there is a change, but the change is triggered later.
When the view is updated, is there an event that I can use and trigger my method, using getLastVisiblePosition?
Please help or tell me what I am doing wrong ;)
Thanks Danail
回答1:
Yes, if you run notifyDatasetChanged(), you need to queue the operation in the post because the view is rendered asynchronously:
listView.post(new Runnable() {
public void run(){
lastPos = listView.getLastVisiblePosition();
}
});
来源:https://stackoverflow.com/questions/6044796/android-using-notifydatasetchanged-and-getlastvisibleposition-when-the-listvi