How to remove focus from SearchView?

I want to remove focus and text from SearchView in onResume() To achieve this you could set your root layout focusable with the android:focusableInTouchMode attribute and request focus on that View in onResume(). For example: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/root_layout” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” android:focusableInTouchMode=”true”> <SearchView android:id=”@+id/search_view” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:iconifiedByDefault=”false”/> </LinearLayout> And then in your … Read more

Android ActionBar Customize Search View

I did a class SearchViewFormatter to format easily the native SearchView android widget. An example: new SearchViewFormatter() .setSearchBackGroundResource(R.drawable.my_bg) .setSearchIconResource(R.drawable.my_ic, true, false) //true to icon inside edittext, false to outside .setSearchVoiceIconResource(R.drawable.my_ic) .setSearchTextColorResource(R.color.my_color) .setSearchHintColorResource(R.color.my_color) .setSearchCloseIconResource(R.drawable.my_ic) .setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) .format(mSearchView);

Android – NullPointerException on SearchView in Action Bar

Try to replace the failing line with: mSearchMenuItem = menu.findItem(R.id.action_search); mSearchView = (EnglishVerbSearchView) MenuItemCompat.getActionView(mSearchMenuItem); Where R.id.action_search is the id of your search item in the menu. EDIT Your manifest should look like that: <activity android:name=”com.bronzelabs.twc.activities.WorkflowListActivity” android:label=”@string/app_name” android:theme=”@style/Theme.AppCompat.Light” > <intent-filter> <action android:name=”android.intent.action.MAIN” /> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter> </activity> <activity android:name=”.activities.SearchResultActivity” android:theme=”@style/Theme.AppCompat.Light” android:launchMode=”singleTop”> <intent-filter> <action android:name=”android.intent.action.SEARCH” /> … Read more

Android – Make whole search bar clickable

This can be simply done by setting Iconified to false on OnClick of SearchView. searchBar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchBar.setIconified(false); } }); Reference: Eric Lui’s answer Hopefully it will help. UPDATE: You can also use it directly in your XML app:iconifiedByDefault=”false”

Implementing SearchView as per the material design guidelines

I tried several material SearchView libraries, but none of them worked good as the one from the support library, so I decided to redesign it, after a lot of work, I am pleased with the result: Here is how you can do it: 1) Add SearchView item to your menu <item android:id=”@+id/m_search” android:icon=”@drawable/ic_action_search” android:title=”@string/search_title” app:actionLayout=”@layout/search_view_layout” … Read more

How to dismiss keyboard in Android SearchView?

I was trying to do something similar. I needed to launch the SearchActivity from another Activity and have the search term appear on the opened search field when it loaded. I tried all the approaches above but finally (similar to Ridcully’s answer above) I set a variable to SearchView in onCreateOptionsMenu() and then in onQueryTextSubmit() … Read more