我使用actionbarsherlock,我想使用操作栏中的编辑文本和一个按钮。 II已经通过许多文件和职位走了,但还没有找到一个解决办法。
I am using actionbarsherlock and I want to use an Edit Text and a Button in the action bar. I I have gone through many documents and posts but haven't found a solution yet.
我如何在Android操作栏中添加一个编辑文本?
How do I add an Edit Text in the Android action bar?
把一个普通的按钮
操作栏中将会看起来非常可怕的,恕我直言。
Putting a regular Button
in the action bar will look fairly awful, IMHO.
话虽这么说,你可以使用安卓actionLayout
在<项目>在你的菜单XML
元素资源。这应指向一个布局XML资源的名称。这个资源会膨胀到操作栏。你可以通过调用获得部件 getActionView()
对应于该&LT的
元素菜单项
对象;项目>
That being said, you can use android:actionLayout
on your <item>
element in your menu XML resource. This should point to the name of a layout XML resource. This resource will be inflated into the action bar. You can get the widgets by calling getActionView()
on the MenuItem
object corresponding to this <item>
element.
下面是证明这是一个示例项目。 下面是对这一技术的文档。
Here is a sample project demonstrating this. Here is the documentation on this technique.