调整大小时 listView 行的冗余更新
我在活动中使用 ListView 和自定义数组适配器(它只是覆盖 getView 方法)来进行某些聊天活动。当我打开软键盘列表视图调整大小(例如从 5 行变为 2 行可见行)时,但 getView 方法调用了 7 次:
07-11 11:59:13.185: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:5 07-11 11:59:13.346: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:4 07-11 11:59:13.485: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:3 07-11 11:59:13.625: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:2 07-11 11:59:13.775: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:1 07-11 11:59:14.015: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:5 07-11 11:59:14.135: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:4
如何防止这种开销?
谢谢帮助。
I'm use ListView in my activity with custom array adapter (it just overrides getView method) for some chat activity. When i open soft keyboard listview resizing (for example from 5 to 2 visible rows), but getView method called 7 times:
07-11 11:59:13.185: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:5 07-11 11:59:13.346: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:4 07-11 11:59:13.485: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:3 07-11 11:59:13.625: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:2 07-11 11:59:13.775: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:1 07-11 11:59:14.015: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:5 07-11 11:59:14.135: DEBUG/*: [ChatMessageArrayAdapter] generating view for pos:4
How do i can prevent this overhead?
thx for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK 这是
getView();
的正常行为您无法阻止对
getView()
的调用,但可以最大限度地减少进程开销。你会使用类似的东西:
AFAIK This is normal Behavior of the
getView();
You cannot prevent the call to the
getView()
but can minimize the process overhead.You would use something like: