я использую следующий файл 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>
я ставлю включают как пустой взгляд для left_drawer (left_drawer.setEmptyView (R.id. progressinformation)).
моя проблема в том, что если listview пуст, когда я нажимаю на навигационный ящик, выбирают элементы, лежащие за ящиком навигации. как избежать этого выбора, когда listview пуст.