ArrayList<HashMap<String, Object>>使用示例!

截取自:http://www.eoeandroid.com/thread-45044-1-1.html

private SimpleAdapter getMenuAdapter(String[] menuNameArray,
                        int[] imageResourceArray) {
                ArrayList<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
                for (int i = 0; i < menuNameArray.length; i++) {
                        HashMap<String, Object> map = new HashMap<String, Object>();
                        map.put("itemImage", imageResourceArray);
                        map.put("itemText", menuNameArray);
                        data.add(map);
                }
                SimpleAdapter simperAdapter = new SimpleAdapter(this, data,
                                R.layout.item_menu, new String[] { "itemImage", "itemText" },
                                new int[] { R.id.item_image, R.id.item_text });
                return simperAdapter;


posted on 2013-01-23 20:34  封起De日子  阅读(319)  评论(0编辑  收藏  举报

导航