4
Android入门第35天-Android里的SubMenu
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.
我们延用在上一篇Menu篇里的例子,把这个ContextMenu里套一层子菜单。
其实,它的原理很简单。
就是在ContextMenu的:public void onCreateContextMenu方法里,用inflator.inflate(R.menu.sub_menu, menu);加载一个外部的sub_menu。
很简单,一点不难。来看代码。
sub_menu.xml
MainActivity.java
我们以Toast来显示不同的子菜单选择后的效果即可。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK