I am trying to imitate the style of how search is handled by the gmail app which looks as follows:
As shown above there is a (blue) blinking cursor after the search query in the searchView.
My respective code looks like this:
SearchReslutActivity.class
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQuery(getIntent().getStringExtra(SearchManager.QUERY), false);
searchView.setIconified(false);
searchView.clearFocus();
return true;
}
menu/search_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/search"
android:title="@string/search_title"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always" /> </menu>
xml/searchable.xml
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/hint"
android:includeInGlobalSearch="true"
android:inputType="textCapWords"
android:label="@string/app_name"
android:searchSuggestAuthority="com.webaddress.myproject.data.Provider"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:searchSuggestIntentData="content://com.webaddress.myproject.data.Provider/table"
android:searchSuggestSelection=" ?"
android:searchSuggestThreshold="1" />
The above code achieves the same look as what is displayed in the gmail app except for having a blinking cursor. How can I add such a blinking cursor without requesting focus on the searchView
(which in turn will make the soft keyboard pop up again)?
Thanks!