android - 导航 View : checkableBehavior ="none" not working on latest version

标签 android android-support-design

我正在使用最新的 Android 设计支持库,并且我的导航 View 有两组,一组用于我使用 android:checkableBehavior="single" 的 fragment ,一组用于设置和关于我所在位置等 Activity 使用android:checkableBehavior="none"

这在库的版本 23.0.1 之前都可以正常工作,现在当我只使用 compile 'com.android.support:design:+' 时,按钮会在选择时被检查。

这只是库中的错误还是我必须为新版本更改某些内容? 我在变更日志中找不到任何内容。

菜单:

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

布局:

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

最佳答案

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

关于android - 导航 View : checkableBehavior ="none" not working on latest version,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33690120/

相关文章:

android - Broadcastreceiver 开机后不工作

android - 如何从 Activity 类更新recyclerview textview

android - 从缓存中加载 webview

android - SwipeRefreshLayout 在将支持库更新到 23.2.0 后阻止 AppBarLayout 向下滚动并显示刷新圈

android - 属性 “”已使用不兼容的格式定义

android - ndk-构建 "member ... in archive is not an object"

android - RxJava : How to find the smaller number in a sequence

android - 如何使用 ItemTouchHelper 及其 Callback 或实现自定义的?

android - 在 SnackBar 上包装内容高度

android - 禁用用户在 BottomSheet 上拖动