public class MainActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//创建SimpleAdapter适配器
SimpleAdapter adapter = new SimpleAdapter(this,getData(),R.layout.imagelistview,
new String[]{"title","info","img"},
new int[]{R.id.title,R.id.message,R.id.image});
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("title", "Android简介");
map.put("message", "google公司");
map.put("image", R.drawable.away);
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "运行第一个Android程序");
map.put("message", "java的环境");
map.put("image", R.drawable.busy);
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "Android的常用UI控件");
map.put("message", "很多中,如TextView、");
map.put("image", R.drawable.msn); list.add(map);
return list;
}
}
运行的最终界面如下: