修改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對象,可以自定義一個類。