List控件的使用1
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList<HashMap<String,String>> list=new ArrayList<HashMap<String,String>>();
HashMap<String,String> map1=new HashMap<String,String>();
HashMap<String,String> map2=new HashMap<String,String>();
HashMap<String,String> map3=new HashMap<String,String>();
HashMap<String,String> map4=new HashMap<String,String>();
map1.put("user_name", "cheng");
map1.put("user_ip", "127.0.0.1");
map2.put("user_name", "chengqing");
map2.put("user_ip", "127.0.0.2");
map3.put("user_name", "chengh");
map3.put("user_ip", "127.0.0.3");
map4.put("user_name", "chengf");
map4.put("user_ip", "127.0.0.4");
list.add(map1);
list.add(map2);
list.add(map3);
list.add(map4);
SimpleAdapter listAdapter=new SimpleAdapter(this,list,R.layout.user,new String[]{"user_name","user_ip"},new int[]{R.id.user_name,R.id.user_ip});
setListAdapter(listAdapter);
}