你是否觉得手机QQ上的好友列表那个控件非常棒? 不是..... 那也没关系,学多一点知识对自己也有益无害。
那么我们就开始吧。
展开型列表控件, 原名ExpandableListView
是普通的列表控件进阶版, 可以自由的把列表进行收缩, 非常的方便兼好看。
首先看看我完成的截图, 虽然界面不漂亮, 但大家可以自己去修改界面。
该控件需要一个主界面XML 一个标题界面XML及一个列表内容界面XML
首先我们来看看 mian.xml 主界面
//该界面非常简单, 只要一个ExpandableListView即可
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
groups.xml 该界面是父标题界面
我们只要放上一个要显示出来的标题TextView控件上去即可
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/textGroup"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="40px"
android:paddingTop="6px"
android:paddingBottom="6px"
android:textSize="15sp"
android:text="No data"
/>
childs.xml 是子控件, 直接显示列表内容
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/textChild"
android:layout_width="fill_parent"
android:layout_height="fill_pa