ListActivity的使用 ① 定义一个类继承自ListActivity ② 声明和定义、初始化一个ArrayList ③ 声明和定义、初始化一个SimpleAdepter ④ LixtView 设置适配器 ⑤ 选项按键事件处理,不需要.setOnItemClickListener(); 直接实现以下方法 public class ListActivityOfMe extends ListActivity {} private ArrayList<Map<String, Object>> arrayList; arrayList= new ArrayList<Map<String, Object>>(); Map<String, Object> map; map= new HashMap<String, Object>(); map.put("System", "Linux"); map.put("Ability", "Cool"); arrayList.add(item); SimpleAdapter adapter; adapter= new SimpleAdapter(this, arrayList, android.R.layout.simple_list_item_1, new String[] { "System" }, new int[] { android.R.id.text1 }); this.setAdapter(adapter);//设置适配器 protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub super.onListItemClick(l, v, position, id); actionTo(position); }
ListActivity的使用
最新推荐文章于 2016-11-20 17:11:37 发布