美好的一天,
我正在尝试使用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>

最佳答案

如下修改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>

08-18 17:39