您的位置:首页 > 编程语言 > Java开发

java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receiv

2015-01-08 15:05 459 查看


意思大体是,你的adapter的内容变化了,但是你的ListView并不知情。请保证你adapter的数据在主线程中进行更改!

public class OrderAdapter extends BaseAdapter {

private ArrayList<Map<String, Object>> lists;
private Context context;
private Handler handler;
private BranchIdCallBack branchIdCallBack;

public OrderAdapter(ArrayList<Map<String, Object>> list, Context context, Handler handler) {
super();
this.lists = list;
this.context = context;
this.handler = handler;
}
@SuppressWarnings("unchecked")
public void setDeviceList(ArrayList<Map<String, Object>> list) {
if (list != null) {
lists = (ArrayList<Map<String, Object>>)list.clone();
notifyDataSetChanged();
}
}

public void clearDeviceList() {
if (lists != null) {
lists.clear();
}
notifyDataSetChanged();
}

@Override
public int getCount() {
return lists==null?0:lists.size();
}


adapter数据发生变化要及时刷新。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐