修改SimpleAdapter裏的數據

修改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對象,可以自定義一個類。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章