SherlockActionBar与AutoCompleteTextView和其他项目 [英] SherlockActionBar with AutoCompleteTextView and other items

查看:136
本文介绍了SherlockActionBar与AutoCompleteTextView和其他项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个行动起来吧 AutoCompleteTextView(可折叠)作为一个菜单项的与其他菜单项类似删除。我使用的 SherlockActionBar的库,以使其与低版本(如2.2,2.3)

I want to have an action bar with AutoCompleteTextView(Collapsible) as a menuItem along with other menuItems like Delete. I am using SherlockActionBar's library to make it compatible with lower version(like 2.2, 2.3).

我的要求是,以显示

  1. 一searchIcon(用于可折叠AutoCompleteTextView)在极端的动作条和右

删除图标上面提到searchIcon的离开了。

现在,当用户点击searchIcon,应该扩大自己覆盖整个动作条(hidinig删除图标)。

我曾试图在布局包两个iconsearch(用于AutoCompleteTextView)和deleteButton,并提供该布局由SherlockActionBar库所提供的操作栏的视图,但它并没有显示任何东西。

I had tried wrapping both the iconsearch(for AutoCompleteTextView) and deleteButton in a layout and providing this layout as a view for action bar provided by SherlockActionBar library but it didn't displayed anything.

然后我尝试添加iconSearch(与属性值的可折叠),并deleteButton作为单独的菜单项(在SherlockActionBar示例所示),但它只是显示actionSearch。

Then I tried adding iconSearch (with attribute value as collapsible) and deleteButton as individual menu items (shown in the SherlockActionBar Samples) but it just displays actionSearch.

我不知道如何来实现相同的使用SherlockActionBar库。我曾尝试通过以下给出的样本,以实现相同的,但无法实现这一点。

I have no idea how to implement the same using SherlockActionBar library. I have tried to implement the same by following the samples given but couldn't achieve this.

任何帮助将是AP preciated ...

Any help would be appreciated...

在此先感谢。

推荐答案

我做了所要求的落实。由于拉法尔Galka 和放大器; andrehsouza 。我不得不结合这两种解决方案(由拉法尔Galka &放大器;的 andrehsouza ),以达到预期的效果。

I am done with the required implementation. Thanks to Rafal Galka & andrehsouza. I had to combine both the solutions (provided by Rafal Galka & andrehsouza) to achieve the desired effect.

我所做的是,我创建了一个menu.xml文件有两个行动项目。其中之一是与正常的图标和标题一个标准动作项目,另一个是与自定义视图。而这个定制的观点是什么,但已根据RES /布局文件夹中定义只是一个简单的AutoCompleteTextView。

What I did is, I created a menu.xml with two action items. One of them is a standard action item with normal icon and title and another one is with the custom view. And this custom view is nothing but just a simple AutoCompleteTextView which has been defined under res/layout folder.

因此​​,这里是我的 RES /菜单/ menu.xml文件

So here is my res/menu/menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/menu_xxx"
        android:showAsAction="ifRoom|withText"
        android:icon="@drawable/drawablexxx"
        android:title="@string/xxx"/>

    <item
        android:id="@+id/menu_search"
        android:actionLayout="@layout/collapsibleactionview"
        android:showAsAction="always|collapseActionView"
        android:title="@string/action_search"/>
</menu>

collapsibleactionview.xml 根据已定义的 RES /布局作为:

and collapsibleactionview.xml has been defined under res/layout as :

<?xml version="1.0" encoding="utf-8"?>
<AutoCompleteTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/edittextcollapsible"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/hint search"
    android:imeOptions="actionSearch"
    android:inputType="text" />

宾果!

这篇关于SherlockActionBar与AutoCompleteTextView和其他项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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