当我再次点击按钮时,我的列表视图会添加旧数据,我想限制数据冗余 [英] When I click on button again my listview apends old data , I want to restrict data redundancy
本文介绍了当我再次点击按钮时,我的列表视图会添加旧数据,我想限制数据冗余的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ListView中加载Json响应但是当我点击加载按钮两次时,它再次在我的列表视图中加载数据
我有什么试过:
showdownline.setOnClickListener(new View.OnClickListener()//点击听众
lv.setAdapter(适配器); //将其添加到适配器
adapter.notifyDataSetChanged();
I am loading the Json Response in a ListView But When I Click on the load button twice it loads data again in my listview
What I have tried:
showdownline.setOnClickListener(new View.OnClickListener() //Click listener
lv.setAdapter(adapter);//adding it to adapter
adapter.notifyDataSetChanged();
推荐答案
您是否记得在连接到适配器的数据集上调用 clear()
方法?
Are you remembering to call the clear()
method on the data set attached to the adapter?
这篇关于当我再次点击按钮时,我的列表视图会添加旧数据,我想限制数据冗余的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文