Android ExpandableListView展开列表控件使用实例

2019-12-10 20:02:23丽君

        android:layout_height="fill_parent"
        android:paddingLeft="40px"
        android:paddingTop="6px"
        android:paddingBottom="6px"
        android:textSize="15sp"
        android:text="No data"
    />

 

</LinearLayout>

 

childs.xml 是子控件, 直接显示列表内容

复制代码 <LinearLayout
    xmlns:android="http://www.easck.com/apk/res/android"
  android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>
    <TextView  
        android:id="@+id/textChild"
   android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:paddingLeft="60px"
        android:paddingTop="10px"
        android:paddingBottom="10px"
        android:textSize="20sp"
   android:text="No Data"
/>

 

</LinearLayout>

 


接下来再上主代码, 命名有点乱, 大家真正用于开发时可不要这样命名啊.

复制代码 public class ExpandActivity extends ExpandableListActivity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        //创建二个一级条目标题
        Map<String, String> title_1 = new HashMap<String, String>();
        Map<String, String> title_2 = new HashMap<String, String>();