Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: ActionBarSherlock search widget

I currently have an application in the play store for both tablets and smartphone runnings Android 3.0+ (http://tinyurl.com/cnejnjs). In order to appeal to more users I am looking into getting the application to work on a large range of devices.

I am aware of ActionBar Sherlock and this seems to do almost everything I want. One thing it does not offer is the Search Widget which I make use of in the current application.

Is there any way to have a search box in the actionbar which updates the current list fragment on screen in a similar way to how the default search widget works?

like image 290
bencallis Avatar asked Mar 29 '12 16:03

bencallis


People also ask

How to add Search icon in ACTION bar android studio?

Add the Search View to the App Bar To add a SearchView widget to the app bar, create a file named res/menu/options_menu. xml in your project and add the following code to the file. This code defines how to create the search item, such as the icon to use and the title of the item.

How to add Search button in android studio?

For instance, you should add a Search button in your Options Menu or UI layout that calls onSearchRequested() . For consistency with the Android system and other apps, you should label your button with the Android Search icon that's available from the Action Bar Icon Pack.

How to implement Android searchview over toolbar in Android?

Android SearchView on ToolBar. As we have already implemented SearchView widget over activity layout, it can also be implemented over ToolBar/ActionBar. For implementing SearchView over ToolBar, we need to create menu option and place SearchView widget on it. Let's us see the example of SearchView over ToolBar and searching data in ListView.

What happened to actionbarsherlock?

ActionBarSherlock is deprecated. No more development will be taking place. For an up-to-date action bar backport use AppCompat. Thanks for all your support! ActionBarSherlock is an standalone library designed to facilitate the use of the action bar design pattern across all versions of Android through a single API.

How do I use the search widget on my Android phone?

Search for information more quickly with the Google app widget on your Home screen. You can control the color, shape, and transparency of the Search widget that appears on your Android phone or tablet. Add the Search widget to your homepage. Learn how to add a widget. On your Android phone or tablet, open the Google app .

What is the best way to backport actionbarsherlock?

For an up-to-date action bar backport use AppCompat. Thanks for all your support! ActionBarSherlock is an standalone library designed to facilitate the use of the action bar design pattern across all versions of Android through a single API. The library will automatically use the native ActionBar implementation on Android 4.0 or later.


1 Answers

The search widget is just a simple expandable action item. You can create your own very easily by using an EditText as the expanded layout. You can see this in the "Collapsible Action Item" example from the Feature Demos (though it is only a very basic example).

You can also use the built-in widget on Honeycomb and up from the compatibility library:

Context context = getSupportActionBar().getThemedContext();
View searchView = SearchViewCompat.newSearchView(context);
if (searchView != null) {
    //Use native implementation
} else {
    //Use simple compatibility implementation
}

Supporting a 99% compatibile implementation is also on the roadmap.

like image 109
Jake Wharton Avatar answered Oct 12 '22 08:10

Jake Wharton