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.clear(); //或者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()就可以