listView用法1

来源:互联网 发布:linux vlan tag 编辑:程序博客网 时间:2024/04/29 03:49
protected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.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;}

原创粉丝点击