我怎么可以在动作条中添加编辑文本字段和按钮? [英] How I can add Edit Text field and button in ActionBar?

查看:94
本文介绍了我怎么可以在动作条中添加编辑文本字段和按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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.

这篇关于我怎么可以在动作条中添加编辑文本字段和按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆