protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getJSONString();
// 定义适配器
SimpleAdapter adapter = new SimpleAdapter(this, getData(),
R.layout.item_notice, new String[] { "type", "context",
"starttime", "endtime", "publishtime" }, new int[] {
R.id.tv_item_type, R.id.tv_item_content,
R.id.tv_item_starttime, R.id.tv_item_endtime,
R.id.tv_item_publistime });
setListAdapter(adapter);
}
private List<Map<String, Object>> getData() {
List<Map<String, Object>> _list = new ArrayList<Map<String, Object>>();
Map<String, Object> _map = new HashMap<String, Object>();
_map.put("type", "紧急");
_map.put("context", "地震了!");
_map.put("starttime", "11");
_map.put("endtime", "22");
_map.put("publishtime", "33");
_list.add(_map);
_map = new HashMap<String, Object>();
_map.put("type", "普通");
_map.put("context", "发大水!");
_map.put("starttime", "33");
_map.put("endtime", "44");
_map.put("publishtime", "55");
_list.add(_map);
return _list;
}
listView用法1
最新推荐文章于 2024-04-06 12:32:32 发布