Can we implement SeachView in Android 2.2 using ActionbarSherlock.
I am using following code, it is working fine in 3.0 but not working in 2.2
@Over
A small update:
Jake Wharton is currently working on ActionBarSherlock 4.2.0 in dev
branch and has SearchView
backported there. It has limited functionality (most notable - no support for SearchableInfo
). But he is working on expanding functionality.
I didn't know about Jake Wharton's intentions on backporting SearchView
and did my version of backport (can be found on github: abs-search-view). My version also does not support SearchableInfo
.
These two implementations were done in mostly the same way. They use much of the same code taken from AOSP. But there are some notable differences.
SearchView
implementation on systems with API 11 and up (i.e. it's the same code with pros and cons on all platforms).SearchView
and all features are supported the way they are described in documentation.Personally, I'd recommend sticking with ActionBarSherlock version (it's just easier that way). And use my library only if you need this fully functional behavior on systems with API 11 and up.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/search"
android:actionLayout="@layout/layout_menu_search"
android:actionViewClass="com.actionbarsherlock.widget.SearchView"
android:icon="@drawable/ic_menu_search"
android:orderInCategory="1"
android:showAsAction="always|collapseActionView"/>
</menu>
Unfortunately, from what I have read and tried, ActionBarSherlock does not support the SearchView widget.
Android is set to release a backwards compatibility package in the future supporting this, but who knows when that will be.
See this link from the man himself: https://github.com/JakeWharton/ActionBarSherlock/issues/70
I had a similar problem, so I created a custom SearchView. Maybe you want to check it out at https://github.com/benjaminmock/MenuItemSearchAction