ExpandableListView二级列表



ExpandableListView继承于ListView
ExpandableListView有如后特殊属性:android:childDivider=""(各组内成员之间的分隔条)
android:childIndicator=""(各组内成员旁边的drawable对象)
android:groupIndicator=""(分组项旁边的drawable对象)

expandableListView..setGroupIndicator(null);// 去掉控件默认箭头


BaseExpandableListAdapter与BaseAdapter的基本原理一样,但是在传入list的时候,要传入两组,一组是groupArray(分组的名称,类似于QQ的“好友”、“同学”、“家人”等分类);一组是childArray,每个元素都是一组子数据(组中的成员,类似QQ“好友”分组的张三、李四的集合)。相比BaseAdapter的关键getView()方法,它关键的是getGroupView()和getChildView()方法,实现方式相同。

属性介绍


divider


这个属性用于设置父类之间的分割线样式,具体的设置见childDivider


childDivider


这个属性是用来设置同一个父项下,子类之间的分割线的样式


dividerHeight


用于设置分割线的高度

groupIndicator


这个属性是用于控制父项前面的小箭头用的,如果想要用自己的图片替换掉那个箭头可以这样写


android:groupIndicator="@drawable/picture"  


在Android Studio中用drawable和mipmap都可以


如果想要去掉那个小箭头,可以写

android:groupIndicator="@null"

indicatorLeft

箭头或者自己设置的图片的右边框距离手机左边边缘的距离,类似于marginLeft

indicatorStart

箭头或者自己设置的图片的左边框距离手机左边边缘的距离,类似于marginLeft

以上两个属性相结合可以使箭头或自己设置的图片变大变小或者翻转,因为控制了箭头或图片的左右边框

childIndicator

用于设置子项前显示的图标,不设置的话默认是没有图标的


系统二级列表适配器列表
SimpleExpandableListAdapter seAdapter = new SimpleExpandableListAdapter( 
                ComAppActivity.this, groupData, 
                android.R.layout.simple_expandable_list_item_1,  
                new String[]{ConmonNumDBContants.COLUMN_NAME},      //Map  键   
                new int[]{android.R.id.text1}, childData,                        

                android.R.layout.simple_expandable_list_item_2, 
                new String[]{ConmonNumDBContants.COLUMN_NAME},     //Map  键

                new int[]{android.R.id.text1,android.R.id.text2});



猜你喜欢

转载自blog.csdn.net/ttxs99989/article/details/80892431