listview数据的添加

/**
* 加载notification内容
*/
private void loadNotifiListView() {
notifiListView = (ListView) findViewById(R.id.notifi_list);
ArrayList list = new ArrayList();
HashMap map;
map = new HashMap();
map.put("id", 1);
map.put("notiIcon", R.drawable.ic_launcher);
map.put("notiInfo",
"您的支付P123456798已经生成,请确认付款之后通过Live Chat联系SEAGM在线客服在核实汇款信息后将为您支付订单。");
map.put("notiTime", "2 hours ago");
list.add(map);
map = new HashMap();
map.put("id", 2);
map.put("notiIcon", R.drawable.ic_launcher);
map.put("notiInfo",
"您的支付P123456798已经生成,请确认付款之后通过Live Chat联系SEAGM在线客服在核实汇款信息后将为您支付订单。");
map.put("notiTime", "2 hours ago");
list.add(map);
SimpleAdapter adapter = new SimpleAdapter(this, list,
R.layout.notification_list_item, new String[] { "notiIcon",
"notiInfo", "notiTime" }, new int[]{R.id.item_image,R.id.item_info,R.id.item_time});
notifiListView.setAdapter(adapter);
notifiListView.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
HashMap map = (HashMap) parent.getItemAtPosition(position);
Log.e("error123", map.get("id").toString());
}
});
}

原文地址:https://www.cnblogs.com/xingmeng/p/2446103.html