我正在使用最新的 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/