Android Create Custom Searchview Search Action
In my application I am using the Action Bar with a custom SearchView in it. I want to use some custom code when the user hits the enter button in the search field. But I cant find
Solution 1:
Get your search view and add an OnQueryTextListener
final SearchView.OnQueryTextListener queryTextListener = newSearchView.OnQueryTextListener() {
@OverridepublicbooleanonQueryTextChange(String newText) {
// Do somethingreturntrue;
}
@OverridepublicbooleanonQueryTextSubmit(String query) {
// Do somethingreturntrue;
}
};
searchView.setOnQueryTextListener(queryTextListener);
By the way my menu layout is as follows;
<item android:id="@+id/menu_search"
android:showAsAction="ifRoom"
android:actionViewClass="android.widget.SearchView" />
Post a Comment for "Android Create Custom Searchview Search Action"