2

Im using the latest Android Design Support Library and have two groups for my Navigation View, one for fragments where I use android:checkableBehavior="single" and one for Activities like Settings and About where I use android:checkableBehavior="none".

This worked fine up to version 23.0.1 of the library, now when I just use compile 'com.android.support:design:+' The buttons get checked when selecting.

Is this just a bug in the library or do I have to change something for the new version? I can't find anything in the changelog.

menu:

<group
    android:id="@+id/main"
    android:checkableBehavior="single">
    <item
        android:id="@+id/navigation_fragment_1"
        android:icon="@drawable/icon"
        android:title="@string/fragment_1" />
</group>

<group
    android:id="@+id/sub"
    android:checkableBehavior="none">
    <item
        android:id="@+id/navigation_sub_settings"
        android:title="@string/settings" />

</group>

</menu>

layout:

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<RelativeLayout
    android:id="@+id/layout_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/toolbar" />
</RelativeLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:headerLayout="@layout/drawer_header"
    app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>
4

1 回答 1

2

我的代码中有一个menuItem.setChecked(true);(这对旧版本没有问题),但我猜他们改变了一些东西,所以现在你可以手动检查 menuItems,即使它们设置为android:checkableBehavior="none".

于 2015-12-04T15:40:07.903 回答