Search Edit Text, e.g. Google Play

How to implement Search Edit text, for example, play on Google using the "Back" and "Cancel" buttons to the right of the voice search and list of offers, should be displayed under the full text editing layout.

enter image description here

+4
source share
2 answers

This is a SearchView with some tweak check docs http://developer.android.com/guide/topics/search/search-dialog.html

The approval is announced as follows

<activity android:name=".SearchableActivity"
          android:launchMode="singleTop" >
    <intent-filter>
        <action android:name="android.intent.action.SEARCH" />
    </intent-filter>
    <meta-data android:name="android.app.searchable"
                      android:resource="@xml/searchable"/>
  </activity>

and SearchView xml

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/search_label"
    android:hint="@string/search_hint"
    android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" >
</searchable>

You also need to override onSearchRequested

@Override
public boolean onSearchRequested() {
     Bundle appData = new Bundle();
     appData.putBoolean(SearchableActivity.JARGON, true);
     startSearch(null, false, appData, false);
     return true;
 }
+3
source

Source: https://habr.com/ru/post/1607584/


All Articles