Android ListView SimpleAdapter ArrayList 数据更新问题
2013-09-12 21:31
826 查看
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()就可以
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()就可以
相关文章推荐
- 【android】Cursor记录集游标、ListView和SimpleCursorAdapter、ListView数据动态更新
- android更新UI的时候通知adapter和赋值listview的问题
- android使用notifyDataSetChanged()方法,adapter的数据更新了,但是ListView的内容没有更新
- 【Android笔记-异常-4】定义一个临时的数组变量承接数据,ListView的数据以及通知数据更新要放到同一个线程(主线程)。避免出现异常"The content of the adapter
- android PagerAdapter notifyDataSetChanged() 无法更新数据问题解决
- android基础笔记——监听数据变化,即时更新ListView:adapter.notifyDataSetChanged();
- Android listview 列表更新数据+重写adapter
- android-分页加载ListView 点击Item获取对象数据及ArrayList重复及乱序问题
- android ListView布局之二(是用simpleAdapter绑定数据)
- android 从activity用intent跳转到listactivity并在其中用simpleadapter在listview中显示数据列
- listView使用simpleAdapter通过notifyDataSetChanged()方法刷新数据问题
- Android ListView的中的数据更新时遇到的一些问题的总结
- Android基础入门教程——2.4.6 ListView的数据更新问题
- Android ListView的适配器 Adapter 中GetView方法调用次数大于数据条数的问题
- android中,用SimpleAdapter创建有自己布局的listView,以及listView的修改更新notifyDataSetChanged()的使用。
- Android SimpleAdapter数据删除后界面更新
- android 从activity用intent跳转到listactivity并在其中用simpleadapter在listview中显示数据列
- android使用notifyDataSetChanged()方法,adapter的数据更新了,但是ListView的内容没有更新;
- Android-----SimpleAdapter创建ListView的实例,及值得注意的一些细节问题
- Adapter类型控件之ListView的数据更新问题