当前位置: 代码迷 >> Android >> ListView notifyDataSetChanged更新疏失
  详细解决方案

ListView notifyDataSetChanged更新疏失

热度:25   发布时间:2016-05-01 10:38:13.0
ListView notifyDataSetChanged更新出错
	
//定义
private ArrayList<HashMap<String, Object>> item;
private SimpleAdapter listItemAdapter;
//初始化

listItemAdapter = new SimpleAdapter(this, item,R.layout.list_item, 
new String[] { "name", "id", "houseNum","meterValue" }, 
new int[] { R.id.item_name,R.id.item_id, R.id.item_house_num,R.id.item_meter_value });
readingMeterList.setAdapter(listItemAdapter);
...

//更新
HashMap<String, Object> map = Activity.this.item.get(index);
map.put("meterValue", String.format("%.2f", meterValue));
item.set(index, map);
listItemAdapter.notifyDataSetChanged();

更新是时候要出错,错误信息如下, 不知道是哪里错了!
ListView

------解决方案--------------------
你是不是在子线程调用notifychanged了?
应该用主线程刷新你的UI。
------解决方案--------------------
引用:
你是不是在子线程调用notifychanged了?
应该用主线程刷新你的UI。

log上是这个意思
  相关解决方案