应用程序中的子菜单 [英] Sub Menu in App
本文介绍了应用程序中的子菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Android 中可以有子菜单吗?
你在 Android 中怎么称呼这个视图?
解决方案
这是一个示例代码
在抽屉布局中,使用一个简单的 ExpandableListView 并对其进行自定义.
通过扩展 BaseExpandableListAdapter 来制作自定义适配器
public class NavAdapter extends BaseExpandableListAdapter{...}
并将 drawerList(ExpandableListView 对象)附加到 ActionBarToggle
actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawer,toolbar,R.string.drawer_open,R.string.drawer_close )
Is having a sub menu possible in Android?
And what do you call this view in Android?
解决方案
Here is a sample code for this https://github.com/D8thReaper/android-navigation-menu-expandable. The sample is in material design and is pretty simple to use.
In the drawer layout, use a simple ExpandableListView and customize it.
<ExpandableListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:dividerHeight="1dp"
android:divider="@color/list_divider"
android:listSelector="@drawable/list_selector"
android:background="@color/list_background" />
Make a custom adapter by extending with BaseExpandableListAdapter
public class NavAdapter extends BaseExpandableListAdapter{...}
And attach the drawerList (ExpandableListView object) to ActionBarToggle
actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawer,toolbar,R.string.drawer_open,R.string.drawer_close )
这篇关于应用程序中的子菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文