ArrayList使用示例!

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

private SimpleAdapter getMenuAdapter(String[] menuNameArray,
                        int[] imageResourceArray) {
                ArrayList> data = new ArrayList>();
                for (int i = 0; i < menuNameArray.length; i++) {
                        HashMap map = new HashMap();
                        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;


转载于:https://www.cnblogs.com/sesexxoo/archive/2013/01/23/6189966.html

你可能感兴趣的:(ArrayList使用示例!)