打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
ListView item被多次重绘的原因是啥
ListView item被多次重绘的原因,经验证,与ListView自身的layout宽高有关:
[java] view plain copy
android:layout_width="match_parent"
android:layout_height="match_parent"
如果可以,请将其宽高都设置为match_parent。,则会极大地减少item的重绘次数,理想情况下是1次。
试验中,listView有一个header、一个footer、5个item,listView的布局为:
[java] view plain copy
android:layout_width="match_parent"
android:layout_height="wrap_content"
结果Log显示:
1.进入页面绘制listview时同一个item被绘制了5次。
2.当点击改变其中的一个item的显示状态后通过“notifyDataSetChanged();”更新时同一个item被绘制了3次。
当把ListView的layout_height由wrap_content改为match_parent时,首次绘制listview,每个item只绘制了一次;点击其中一个item改变其状态后通过“notifyDataSetChanged();”更新时,每个item也只被绘制了一次。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
关于Adapter的notifyDataSetChanged是否生效
使用ListView应该注意的地方
The content of the adapter has changed but Li...
【新提醒】利用ListView实现新闻客户端的新闻内容图文混排
listview怎样设置每个Item的高度?
C# ListView 选中状态的判断方法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服