简体   繁体   English

当我在活动布局中有 DrawerLayout 时,ListView 不起作用

[英]ListView doesn't work when i have DrawerLayout in Acivity Layout

Drawerlayout conflict with ListView in Activity Layout. Drawerlayout 与 Activity Layout 中的 ListView 冲突。 but only ListView works fine and only DrawerLayout works fine too.但只有 ListView 工作正常,只有 DrawerLayout 工作正常。 problem is if they work together问题是如果他们一起工作

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/diary_layout"
        android:background="@drawable/activebg">

        <ListView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="30dp"
            android:layout_marginTop="20dp"
            android:listSelector="@android:color/transparent"
            android:id="@+id/diary_list">
        </ListView>


        <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">

            <ListView android:id="@+id/navList"
                android:layout_width="240dp"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                android:choiceMode="singleChoice"
                android:divider="@android:color/transparent"
                android:dividerHeight="0dp"
                android:background="#111"/>
        </android.support.v4.widget.DrawerLayout>





    </RelativeLayout>

in this situation when i have drawer layout listview doesn't work (not click, not scroll).在这种情况下,当我有抽屉布局时,listview 不起作用(不是点击,不是滚动)。 if remove如果删除

<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">

        <ListView android:id="@+id/navList"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            android:background="#111"/>
    </android.support.v4.widget.DrawerLayout>

this block listview works fine.这个块列表视图工作正常。 can anyone help me ?谁能帮我 ?

Difference is that, in my example i use ListView(not ScrollView), there is solved this problem 

Android ScrollView 不会在带有抽屉布局的 Activity 中滚动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM