单击导航抽屉中的菜单项后如何打开子菜单?
我实现了一个带有导航视图的导航抽屉.而且我正在通过menu.xml文件在导航视图中增加价值.
I implemented a navigation drawer, with navigation view. and i am adding value in navigation view through a menu.xml file.
<android.support.design.widget.NavigationView
android:id="@+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:itemTextColor="@android:color/white"
android:background="?attr/colorAccent"
app:menu="@menu/drawer_view"
app:headerLayout="@layout/nav_header"
>
</android.support.design.widget.NavigationView>
一切正常,但是我遇到了一个问题,我想在菜单上单击后显示子菜单.
every thing is working fine, but i am facing a problem, I want to display submenu's , after click on menu.
我尝试了很多事情,例如:-
I tried many thing's like:-
我在菜单项中的menu.xml中添加子菜单. 这样的东西.
I add submenu in menu.xml, inside item. somthing like this..
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_ChangeOutlet_fragment"
android:icon="@drawable/home_icon"
android:title="@string/changeOutlet"
android:checked="true">
<menu>
<group>
<item
android:title="one"></item>
<item
android:title="two"></item>
<item
android:title="three"></item>
</group>
</menu>
然后它像这样返回我的输出.
then it return me output like this.
输出:单击此链接以查看输出
Output: click on this link to see output
https://drive.google.com/file/d/0B0B9-WZYydK7RG1yY0tRdkhOSWW8 /view?usp =共享
现在的问题是,以这种方式我无法单击menu,只有子菜单可在此处单击.
Now problem is that, in this way i am not able to click on menu , only sub menu are clickable here.
我要在这里显示子菜单,仅在单击菜单后,否则子菜单确实显示给其他人或说它处于不可见状态
I want here to show sub menu , only after click on menu, otherwise sub menu does shown to other or say it is in invisible state
您可以使用ExpandableListview创建它.
You can create it using a ExpandableListview.
看看这个