将ListView添加到SlidingDrawer中?

时间:2011-05-14 18:52:05

标签: android listview slidingdrawer

如何将ListView充气到SlidingDrawer?输入的Thnx。

main.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<WebView android:id="@+id/webView1" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
</WebView>

<include android:id="@+id/windowTitle" layout="@layout/window_title" />
<include android:id="@+id/slidingDrawer" layout="@layout/sliding_drawer" />

</FrameLayout>

抽屉XML:

<SlidingDrawer android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer" android:handle="@+id/handle" android:content="@+id/content"
android:allowSingleTap="false">

<LinearLayout android:id="@+id/handle"
    android:orientation="horizontal" android:layout_width="fill_parent"
    android:layout_height="20dip" android:background="@drawable/gradient2">

    <ImageView android:id="@+id/handleGrip" android:src="@drawable/handle"
        android:layout_height="wrap_content" android:gravity="center"
        android:layout_centerInParent="true" android:layout_gravity="center"
        android:layout_width="match_parent" />

</LinearLayout>

<ListView android:id="@+id/content" android:layout_height="match_parent"
    android:background="#000" android:layout_width="wrap_content" />

</SlidingDrawer>

1 个答案:

答案 0 :(得分:2)

你必须做这样的事情。

<SlidingDrawer android:id="@+id/drawer" android:handle="@+id/handle"
    android:content="@+id/content" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:orientation="vertical"
    android:layout_gravity="bottom">

    <LinearLayout android:id="@id/content"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="Below there is a list view." />

        <ListView android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:id="@+id/listview_"
            android:divider="@android:color/transparent" 
            android:dividerHeight="10.0sp" />

    </LinearLayout>

    <ImageView android:id="@id/handle" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:background="@drawable/icon" />

</SlidingDrawer>