【SimpleAdapter用法】
public class TestSimpleAdapter extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.testsimpleadapter); mListView = (ListView) findViewById(R.id.mySimpleList); mAdapter = new SimpleAdapter(this, getData(), R.layout.simpleitem, new String[]{"image", "title", "info"}, new int[]{R.id.img, R.id.title, R.id.info}); mListView.setAdapter(mAdapter); } private List<HashMap<String, Object>> getData() { mHashMaps = new ArrayList<HashMap<String,Object>>(); map = new HashMap<String, Object>(); map.put("image", R.drawable.gallery_photo_1); map.put("title", "G1"); map.put("info", "google 1"); mHashMaps.add(map); map = new HashMap<String, Object>(); map.put("image", R.drawable.gallery_photo_2); map.put("title", "G2"); map.put("info", "google 2"); mHashMaps.add(map); map = new HashMap<String, Object>(); map.put("image", R.drawable.gallery_photo_3); map.put("title", "G3"); map.put("info", "google 3"); mHashMaps.add(map); return mHashMaps; } }
参考:http://www.cnblogs.com/shang53880/archive/2011/03/15/1985062.html