gpt4 book ai didi

android - 主要内容可从抽屉导航框架访问。

转载 作者:太空狗 更新时间:2023-10-29 14:16:16 25 4
gpt4 key购买 nike

我在抽屉导航中使用以下 xml 文件

XML:

<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<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">

<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->



<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>






</FrameLayout>

<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
The drawer is given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view. -->



<RelativeLayout
android:layout_width="240dp"
android:layout_height="fill_parent"
android:layout_gravity="start"
android:id="@+id/drawer_frame"
android:background="@drawable/list_selector"

>

<LinearLayout
android:id="@+id/header"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:background="@drawable/list_selector"
android:clickable="true"
android:onClick="Login"
>

<ImageView
android:id="@+id/DisplayImage"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="5dp"
android:src="@drawable/displayimage"
android:contentDescription="@string/contentdescription"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="vertical" >

<TextView
android:id="@+id/Displayname"
android:layout_marginLeft="3dp"
android:layout_marginTop="5dp"
android:layout_marginRight="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/counter_text_color"
android:textSize="14sp"
android:text="@string/Signin"
android:gravity = "center"
/>

</LinearLayout>

</LinearLayout>

<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@color/card_background"
android:dividerHeight="1dp"
android:background="@drawable/list_selector"
android:layout_marginTop="5dp"
android:layout_below="@+id/view1"
/>

<include android:id="@+id/progressinformation" layout="@layout/emptyview"/>

<View
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/header"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="@color/card_background"

/>

</RelativeLayout>

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

我正在将 include 设置为 left_drawer 的空 View (left_drawer.setEmptyView(R.id.progressinformation))。

我的问题是,假设当我单击抽屉导航时 ListView 为空,抽屉导航后面的元素正在选择。如何在 ListView 为空时避免此选择。

最佳答案

不确定是否理解正确但你必须将抽屉导航布局参数clickable设置为true

<RelativeLayout
android:layout_width="240dp"
android:layout_height="fill_parent"
android:layout_gravity="start"
android:id="@+id/drawer_frame"
android:background="@drawable/list_selector"
android:clickable="true"
>

关于android - 主要内容可从抽屉导航框架访问。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21752535/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com