android--------ExpandableListView的使用多级列表
2016-09-14 15:19
579 查看
多级列表ExpandableListView
扩展列表能够显示一个指示在每项显示项的当前状态(状态通常是一个扩展的组,组的孩子,或倒塌,最后一个孩子)。使用setchildindicator(drawable)或setgroupindicator(drawable)(或相应的XML属性)来设置这些指标,一个默认的风格多级列表提供指标,将示给意见多级列表。布局android.r.layout.simple_expandable_list_item_1和android.r.layout.simple_expandable_list_item_2(应用simplecursortreeadapter)包含位置信息的首选指标。
效果图:
源代码下载
扩展列表能够显示一个指示在每项显示项的当前状态(状态通常是一个扩展的组,组的孩子,或倒塌,最后一个孩子)。使用setchildindicator(drawable)或setgroupindicator(drawable)(或相应的XML属性)来设置这些指标,一个默认的风格多级列表提供指标,将示给意见多级列表。布局android.r.layout.simple_expandable_list_item_1和android.r.layout.simple_expandable_list_item_2(应用simplecursortreeadapter)包含位置信息的首选指标。
效果图:
public class MainActivity extends Activity { private ExpandableListView listView; private List<String> group; private List<List<String>> child; private MyAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView = (ExpandableListView) findViewById(R.id.expandableListView); /** * 初始化数据 */ initData(); adapter = new MyAdapter(this,group,child); listView.setAdapter(adapter); } private void initData() { group = new ArrayList<String>(); child = new ArrayList<List<String>>(); addInfo("笑傲江湖",new String[]{"东方不败","风清扬","令狐冲","岳不群"}); addInfo("天龙八部", new String[]{"乔峰","虚竹","段誉"}); addInfo("九阴真经", new String[]{"中神通","东邪","西毒","南帝","北丐"}); } /** * 添加数据信息 * @param g * @param c */ private void addInfo(String g,String[] c) { group.add(g); List<String> list = new ArrayList<String>(); for (int i = 0; i < c.length; i++) { list.add(c[i]); } child.add(list); } }
源代码下载
相关文章推荐
- Android多级列表ExpandableListView使用实例
- android--------ExpandableListView的使用多级列表
- android--------ExpandableListView的使用多级列表
- Android UI编程(2)——多级列表(ExpandableListView)
- Android基础入门教程——2.4.12 ExpandableListView(可折叠列表)的基本使用
- Android之用 ExpandableListView使用解析(三级列表的实现)
- android开发之ExpandableListView的使用,实现类似QQ好友列表
- Android::ExpandableListView二级列表控件的使用
- 一看就会Android之分组列表组件ExpandableListView的使用
- android 扩展列表ExpandableListView的详解和使用
- 仿QQ列表--Android控件ExpandableListView的使用
- Android中可展开的列表组件(ExpandableListView)的使用
- android开发之ExpandableListView的使用,实现类似QQ好友列表
- Android ExpandableListView使用(3): ExpandableListView实现三级列表
- Android ExpandableListView展开列表控件使用实例
- Android中级联列表ExpandableListView使用
- Android UI开发第二篇——多级列表(ExpandableListView)
- Android UI开发第二篇——多级列表(ExpandableListView)
- Android中级联列表ExpandableListView使用
- android开发之ExpandableListView的使用,实现类似QQ好友列表