读书人

Android ListView SimpleAdapter Arra

发布时间: 2012-11-06 14:07:00 作者: rapoo

Android ListView SimpleAdapter ArrayList 数据更新问题 zhuan
Android ListView SimpleAdapter ArrayList 数据更新问题
2011-05-24 18:52
private GridView myListView;
private SimpleAdapter mySimperAdapter;
private ArrayList<HashMap<String, Object>> myData;



public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.position);

  arrayList = new ArrayList<HashMap<String, Object>>(); //只能初始化一次 否者改变不了
}


public void SetData()
{

  arrayList.removeAll(arrayList);

  for(){

  HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("1", "");
hashMap.put("2", "");
arrayList.add(hashMap);

  }
}
private void Init()
{
mySimperAdapter = new SimpleAdapter(this, arrayList,
R.layout.main, new String[] {"1", "2"}, new int[]{R.id.li1, R.id.li2});
myListView.setAdapter(mySimperAdapter);
}



修改myData的数据以后,调用mySimpleAdapter.notifyDataChanged()就可以

1 楼 ddt2008 2011-11-17 mySimpleAdapter.notifyDataChanged()
这个能用?
有点怀疑 2 楼 yunshangbuhe 2011-11-19 ddt2008 写道mySimpleAdapter.notifyDataChanged()
这个能用?
有点怀疑
怀疑什么呢?您可以自己试试啊

读书人网 >Android

热点推荐