当前位置: 代码网 > it编程>App开发>Android > Android Listview notifyDataSetChanged() 不起作用的解决方案

Android Listview notifyDataSetChanged() 不起作用的解决方案

2024年08月03日 Android 我要评论
android listview notifydatasetchanged() 不起作用private arraylist<map<string, string>> data

android listview notifydatasetchanged() 不起作用

private arraylist<map<string, string>> data = new arraylist<map<string, string>>();  
private arraylist<map<string, string>> delivered_data= new arraylist<map<string, string>>();  

如果直接将arraylist 的数据直接复制,无法完成更新

data = delivered_data;
adapter.notifydatasetchanged();

单个元素改变时候,可以更新

data.get(position).put("status", select[0]);  //change the status 
adapter.notifydatasetchanged();

如果要以数据list直接传递,需要用下面方法

 data.clear();
 data.addall(delivered_data);
 adapter.notifydatasetchanged();

更改listview用到下面项目中:

到此这篇关于android listview notifydatasetchanged() 不起作用的文章就介绍到这了,更多相关android listview notifydatasetchanged内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com