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?
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.
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.
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.
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.
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 .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With