2

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

1 回答 1

-1

修改你的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>
于 2014-06-27T08:56:18.757 回答