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的使用
最新推荐文章于 2025-12-23 21:49:32 发布
本文详细介绍如何使用Android中的ListActivity创建列表应用。主要内容包括:通过继承ListActivity定义类;使用ArrayList和SimpleAdapter管理数据;设置ListView的适配器;实现选项按键事件处理。适合初学者学习。
1万+

被折叠的 条评论
为什么被折叠?



