我可以在导航抽屉中添加多个列表视图吗?

时间:2013-08-05 19:22:43

标签: android android-layout navigation-drawer

美好的一天, 我正在尝试使用ListView和更多视图创建导航抽屉。

我的问题是,当我尝试点击其他视图时,点击未注册

请告诉我是否可以创建一个复杂的视图结构作为导航抽屉?

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<!-- The main content view -->

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
<!-- The navigation drawer -->

<LinearLayout
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@color/charcoal"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp"
    android:orientation="vertical"
    android:showDividers="middle" >

    <ListView
        android:id="@+id/home_drawer_lv_accounts"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:choiceMode="singleChoice"
        android:divider="@color/amazon"
        android:dividerHeight="5dp" >
    </ListView>

    <CheckedTextView
        android:id="@+id/home_drawer_cv_banks"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/health"
        android:focusable="true"
        android:gravity="center"
        android:text="@string/text_all_banks"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#FFF" />
</LinearLayout>

</android.support.v4.widget.DrawerLayout>

1 个答案:

答案 0 :(得分:-1)

修改ur xml如下

<LinearLayout
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@color/charcoal"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp"
    android:orientation="vertical"
    android:showDividers="middle" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <ListView
            android:id="@+id/home_drawer_lv_accounts"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_red_light"
            android:choiceMode="singleChoice"
            android:divider="@android:color/black"
            android:dividerHeight="5dp" >
        </ListView>

        <CheckedTextView
            android:id="@+id/home_drawer_cv_banks"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@android:color/holo_red_light"
            android:focusable="true"
            android:text="Some Dummy Text"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#FFF" />
    </RelativeLayout>
</LinearLayout>