问题描述
我想添加自定义下拉菜单的动作条在我的项目类似于一个可在谷歌图书应用程序(屏幕)上找到。在这种情况下,再书的内容presents完整的表格。
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.
我试图按照从开发者网站的指南,其中有一个例如用SpinnerAdapter 。但是,当我使用自定义布局(在我的情况下,RelativeLayout的两个TextViews的话)我得到一个异常,说ArrayAdapter需要的资源ID是一个TextView。所以我解雇我的想法与下拉但后来我发现,在图书应用至极的下拉看起来对我来说,他们使用的自定义布局,以及因为它看起来对我来说,两个单TextViews在一个布局。
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?
推荐答案
对我来说,这看起来像选项菜单 - 这就是选项菜单项不松口的动作栏本身出现。使用 onCreateOptionsMenu()
并添加任何项目要在菜单
。
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 the Menu
.
编辑:
抱歉,截图是有点混乱。有两种可能性,我可以看到:
Sorry, the screenshot was a bit confusing. There are two possibilities that I can see:
- 这可能是一个子菜单的动作栏项目的 - 我还没有发挥的子菜单和操作栏,但(尽管这提醒了我,我需要做的...)
- 这可能是一个
的PopupMenu
绑在自定义操作栏查看
这篇关于如何创建在蜂窝动作条自定义下拉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!