Skip to main content

Posts

Showing posts from August, 2015

Example for using SearchView in ActionBar

Beginning in Android 3.0, using the SearchView widget as an item in the action bar is the preferred way to provide search in your app. Like with all items in the action bar, you can define the SearchView to show at all times, only when there is room, or as a collapsible action, which displays the SearchView as an icon initially, then takes up the entire action bar as a search field when the user clicks the icon. Create your menu.xml as following. &ltmenu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".UploadActivity"&gt &ltitem android:id="@+id/search" android:icon="@android:drawable/ic_menu_search" app:actionViewClass="android.support.v7.widget.SearchView" android:title="@string/action_search" app:showAsActi...