Sub Menu in App

2019-01-24 22:03发布

Is having a sub menu possible in Android?

And what do you call this view in Android?

submenu

4条回答
smile是对你的礼貌
2楼-- · 2019-01-24 22:33

I think you're looking for ExpandableListView.

查看更多
唯我独甜
3楼-- · 2019-01-24 22:36

As others have mentioned, this is an ExpandableListView, within a NavigationDrawer. There are several tutorials you can use (see my list below).

One piece of advice based on personal experience: the baseline behavior for the SimpleExpandableListAdapter is pretty limiting and often not what you're looking for in your customization. If you're looking to have your own specific behavior and look-and-feel to the sub menus, I highly recommend looking into extending the BaseExpandableListAdapter yourself and creating your own custom adapter. [This may seem daunting at first, but it's not terribly hard once you have a grasp on your parents and children within your menu and sub menu(s).]

查看更多
Animai°情兽
4楼-- · 2019-01-24 22:55

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.

Screenshot

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 )
查看更多
Lonely孤独者°
5楼-- · 2019-01-24 22:56

That menu called Navigation drawer... Check this link it will guide you. The below link also will guide you...

NavigationDrawer

查看更多
登录 后发表回答