导航视图:checkableBehavior="none" 不适用于最新版本
Navigation View: checkableBehavior="none" not working on latest version
我使用最新的 Android 设计支持库,我的导航视图有两组,一组用于我使用 android:checkableBehavior="single"
的片段,另一组用于我使用的设置和关于 [=] 等活动14=].
这在库的 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);
(这对旧版本没有问题)但我猜他们改变了一些东西所以现在你可以手动检查 menuItems 即使它们被设置为 android:checkableBehavior="none"
.
我使用最新的 Android 设计支持库,我的导航视图有两组,一组用于我使用 android:checkableBehavior="single"
的片段,另一组用于我使用的设置和关于 [=] 等活动14=].
这在库的 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);
(这对旧版本没有问题)但我猜他们改变了一些东西所以现在你可以手动检查 menuItems 即使它们被设置为 android:checkableBehavior="none"
.