安卓:使用notifyDataSetChanged和getLastVisiblePosition - 当ListView的实际更新? [英] Android: using notifyDataSetChanged and getLastVisiblePosition - when the listView is actually updated?

查看:531
本文介绍了安卓:使用notifyDataSetChanged和getLastVisiblePosition - 当ListView的实际更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用getLastVisiblePosition(),显然它不是此方法(notifyDataSetChanged)被调用后给我正确的号码。我觉得这个方法只通知认为,有变化,但变化后触发。

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.

在视图更新时,是没有办法,我可以使用,引发我的方法,使用getLastVisiblePosition事件?

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 ;)

谢谢 Danail

推荐答案

是的,如果你运行 notifyDatasetChanged(),你需要排队的<$ c中的操作$ C>后因为视图是异步呈现:

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();
       } 
     });

这篇关于安卓:使用notifyDataSetChanged和getLastVisiblePosition - 当ListView的实际更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆