4

Android入门第35天-Android里的SubMenu

 1 year ago
source link: https://blog.csdn.net/lifetragedy/article/details/128028872
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

我们延用在上一篇Menu篇里的例子,把这个ContextMenu里套一层子菜单。

8e420ee76edd47199fd9325b2757eb46.png

其实,它的原理很简单。

就是在ContextMenu的:public void onCreateContextMenu方法里,用inflator.inflate(R.menu.sub_menu, menu);加载一个外部的sub_menu。

dd06ad886f9f48b69ce8e3b5e2b03d64.png

很简单,一点不难。来看代码。

sub_menu.xml

MainActivity.java



newCodeMoreWhite.png

我们以Toast来显示不同的子菜单选择后的效果即可。

948bb2382287454eb7d1706d6825399e.png

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK