簡體   English   中英

使用ListView代替菜單的導航抽屜

[英]Navigation drawer with ListView instead menu

我在活動菜單中使用動態ListView(而不是菜單)制作了一個自定義導航抽屜。 導航抽屜本身可以正常工作,但是所有視圖(按鈕\\復選框等)在OnClickListener上均不起作用。 在此之前,一切正常,在其他激活中,一切正常。

<?xml version="1.0" encoding="utf-8"?>


<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"><android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_marginTop="16dp"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_fz_main" />

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="54dp"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">


    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true">

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

            <include layout="@layout/nav_header_fz_main" />

            <ImageView
                android:id="@+id/nwBackButton"
                android:layout_width="50dp"
                android:layout_height="34dp"
                android:layout_margin="8dp"
                android:visibility="gone"
                app:srcCompat="@drawable/ic_backspace" />

            <ListView
                android:id="@+id/left_drawer"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                android:choiceMode="singleChoice"
                android:divider="@android:color/transparent"
                android:dividerHeight="0dp" />
        </LinearLayout>
    </android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout></android.support.design.widget.CoordinatorLayout>

在主動式黃油刀初始化中以及在導航抽屜中不再起作用

在onCreate中:

setSupportActionBar(toolbar);
toolbar.setTitle(getResources().getString(R.string.app_name));
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
        this, drawer, toolbar,
        R.string.navigation_drawer_open,
        R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

對不起我的英語不好。 有人可以幫助我嗎?

我發現問題只是添加到內容布局

        content.bringToFront();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM