修改SimpleAdapter里的数据

来源:互联网 发布:js实现简单的字数增加 编辑:程序博客网 时间:2024/05/16 07:39

修改SimpleAdapter里的数据,在如下第二个for语句里:

ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();for(int i = 0; i < cursor.getCount(); i++,cursor.moveToNext()){HashMap<String, String> hp = new HashMap<String, String>();hp.put("name", cursor.getString(1));hp.put("num", cursor.getString(2));list.add(hp);}SimpleAdapter simpleAdapter = new SimpleAdapter(this, list,R.layout.item_list_fragment4, new String[] { "name", "num" },new int[] { R.id.tv_reference_num1, R.id.tvNum });listview.setAdapter(simpleAdapter);for(int i = 0; i < list.size(); i++){@SuppressWarnings("unchecked")HashMap<String, String> hp = (HashMap<String, String>) simpleAdapter.getItem(i);if(hp.get("num").equals("0")){hp.put("num", "");}}

但是要修改字体大小,不能直接初始化SimpleAdapter对象,可以自定义一个类。

0 0
原创粉丝点击