added in version 22.1.0
belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1
Deprecated since version 27.1.0

SearchFragment

public class SearchFragment
extends Fragment

java.lang.Object
   ↳ android.app.Fragment
     ↳ android.support.v17.leanback.app.SearchFragment


This class was deprecated in API level 27.1.0.
use SearchSupportFragment

A fragment to handle searches. An application will supply an implementation of the SearchFragment.SearchResultProvider interface to handle the search and return an ObjectAdapter containing the results. The results are rendered into a RowsFragment, in the same way that they are in a BrowseFragment.

A SpeechRecognizer object will be created for which your application will need to declare android.permission.RECORD_AUDIO in AndroidManifest file. If app's target version is >= 23 and the device version is >= 23, a permission dialog will show first time using speech recognition. 0 will be used as requestCode in requestPermissions() call. setSpeechRecognitionCallback(SpeechRecognitionCallback) is deprecated.

Speech recognition is automatically started when fragment is created, but not when fragment is restored from an instance state. Activity may manually call startRecognition(), typically in onNewIntent().

Summary

Nested classes

interface SearchFragment.SearchResultProvider

Search API to be provided by the application. 

Inherited constants

From interface android.content.ComponentCallbacks2

Public constructors

SearchFragment()

Public methods

static Bundle createArgs(Bundle args, String query, String title)
static Bundle createArgs(Bundle args, String query)
void displayCompletions(CompletionInfo[] completions)

Displays the completions shown by the IME.

void displayCompletions(List<String> completions)

Displays the completions shown by the IME.

Drawable getBadgeDrawable()

Returns the badge drawable in the search bar.

Intent getRecognizerIntent()

Returns an intent that can be used to request speech recognition.

RowsFragment getRowsFragment()

Returns RowsFragment that shows result rows.

String getTitle()

Returns the title set in the search bar.

static SearchFragment newInstance(String query)

Creates a search fragment with a given search query.

void onCreate(Bundle savedInstanceState)
View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)