如何创建像 Google Chrome 应用程序这样的自定义子菜单 [英] How to create custom sub menu like Google Chrome application
问题描述
我想实现自定义子菜单,就像 Android 中的 Google Chrome 一样.
I would like to implement custom sub menu like the one Google Chrome have in the android.
我不确定它是使用 SubMenu
还是 PopupMenu
实现的.
I am not sure if it is implemented using SubMenu
or PopupMenu
.
任何指南或帮助将不胜感激.
any guide or help would be greatly appreciated.
推荐答案
任何 ListView
都可以与 HeaderViewListAdapter
关联,使用它你可以附加单独的布局作为标题和或页脚到您的列表视图.因此,您可以将顶部的三个按钮作为标题视图,而将其余按钮作为普通列表项.当您想要显示菜单时,只需在屏幕的任何适合您需要的部分上扩展并显示此 ListView.
Any ListView
can be associated with HeaderViewListAdapter
, using this you can attach seperate layouts as a header and or footer to your listViews. So you can have the three buttons on top as a header view, and the rest of them as normal list items. When you want to show the menu, just inflate and display this ListView over whichever part of the screen suits your needs.
您还可以将 ListPopupWindow
与 HeaderViewListAdapter
一起使用.
You can also use ListPopupWindow
with HeaderViewListAdapter
s.
在 Android 文档中:HeaderViewListAdapter 和 ListPopupWindow
In the Android documentation: HeaderViewListAdapter and ListPopupWindow
这篇关于如何创建像 Google Chrome 应用程序这样的自定义子菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!