【发布时间】:2015-09-16 17:16:24
【问题描述】:
我在导航抽屉中实现了新的导航视图。现在我想在几个登录和注销条件下隐藏和显示注销菜单项。
这是我的导航视图菜单项
<group android:checkableBehavior="single">
<item
android:id="@+id/home"
android:checked="false"
android:icon="@drawable/drawer_ic_home"
android:title="@string/home_string" />
<item
android:id="@+id/offer_coffee"
android:checked="false"
android:icon="@drawable/drawer_ic_offer_coffee"
android:title="@string/offer_coffee_string" />
<item
android:id="@+id/share_coffee"
android:checked="false"
android:icon="@drawable/drawer_ic_share_coffee"
android:title="@string/share_coffee_string" />
<item
android:id="@+id/take_coffee"
android:checked="false"
android:icon="@drawable/drawer_ic_take_coffee"
android:title="@string/take_coffee_string" />
<item
android:id="@+id/offer_status"
android:checked="false"
android:icon="@drawable/drawer_ic_coffee"
android:title="@string/offer_status"
/>
<item
android:id="@+id/about_us"
android:checked="false"
android:icon="@drawable/drawer_ic_about_us"
android:title="@string/about_us_string" />
<item
android:id="@+id/logout"
android:checked="false"
android:icon="@drawable/logout"
android:title="@string/logout" />
</group>
如果我没有登录,我想隐藏 Logout 项,如果我正在登录,那么我想显示这个子菜单。
我已经看到了几个链接,但它们都在处理一组项目,但在我的情况下,我必须访问该组中名为 Logout 的单个子菜单项。
【问题讨论】:
-
好像不太对劲。 Navigation Drawer 基本上是
ListView,您在上面放置的代码用于工具栏菜单。你确定你在这里输入了正确的代码吗? -
它是一种新的导航视图设计模式,见这里stackoverflow.com/questions/30695038/…
标签: android android-navigation navigationview