在Arrayadapter更新数据 [英] Update data in Arrayadapter

查看:966
本文介绍了在Arrayadapter更新数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题,我有

private ArrayList<CustomItem> items; 
private ArrayAdapter<CustomItem> arrayAdapter;

我显示的项目的数据present,这个数据在我的列表视图看,现在我想更新数据,看看这个新的数据

i show the data present in items, this data i see in listview, now i want to update data and see this new data

if (!items.isEmpty()) {
    items.clear(); // i clear all data
    arrayAdapter.notifyDataSetChanged(); // first change
    items = getNewData();// insert new data and work well
    arrayAdapter.notifyDataSetChanged();  // second change                                      
}

在第一个变化,我看到的数据进行清洗,但在第二个变化我没有看到列表视图中的新数据,我检查和项目做不空

in the first change i see the data are cleaned, but in second change i don't see the new data in listview, i check and the item don't empty

我不知道哪里是错误,你能帮我吗?
最好regads
安东尼奥

i don't know where is the error, can you help me? best regads Antonio

推荐答案

假设getNewData()函数返回的ArrayList&LT; CustomItem的&GT; ,您可以更改该行:

Assuming the getNewData() function returns ArrayList<CustomItem>, can you change the line:

items=getNewData();

items.addAll(getNewData());

,看看是否能工作?

and see if that works?

这篇关于在Arrayadapter更新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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