如何在 Honeycomb ActionBar 中创建自定义下拉菜单?
我想在我的项目中的操作栏中添加一个自定义下拉菜单,类似于可以在谷歌图书应用程序(屏幕)中找到。 在本例中,它代表了本书的完整目录。
我尝试按照开发人员网站的指南进行操作,其中有一个 示例SpinnerAdapter。但是当我使用自定义布局(在我的例子中是一个带有两个 TextView 的relativelayout)时,我得到一个异常,说“ArrayAdapter 要求资源 ID 是一个 TextView”。所以我放弃了我对下拉菜单的想法,但后来我发现书籍应用程序中的下拉菜单在我看来似乎也使用了自定义布局,因为它在我看来就像一个布局中的两个单独的 TextView。
如果我想做的事情可能的话,有人可以告诉我吗?如何做?
I would like to add a custom pulldown menu to the actionbar in my project similar to the one that can be found in the google books app (screen).
In this case it represents the complete table of contents of the book.
I tried to follow the guide from the developer site where there is an example with a SpinnerAdapter. But when i use a custom Layout (in my case a RelativeLayout with two TextViews in it) i get an Exception that saying "ArrayAdapter requires the resource ID to be a TextView". So i dismissed my idea with the pulldown but then i found the pulldown in the books app wich looks to me like they used a custom layout as well because it looks to me like two single TextViews in one Layout.
Could anybody please enlighten me if what i want to do is even possible and how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,这看起来像选项菜单——这就是未提升到操作栏本身的选项菜单项的显示位置。使用
onCreateOptionsMenu()
并将您想要的任何项目添加到Menu
中。编辑:
抱歉,屏幕截图有点令人困惑。我可以看到两种可能性:
PopupMenu
栏查看
To me, that looks like the options menu -- that's where options menu items not promoted to the action bar itself appear. Use
onCreateOptionsMenu()
and add whatever items you want to theMenu
.EDIT:
Sorry, the screenshot was a bit confusing. There are two possibilities that I can see:
PopupMenu
tied to a custom action barView