java.lang.Object | ||
↳ | android.support.v4.app.Fragment | |
↳ | android.support.v17.leanback.app.SearchSupportFragment |
A fragment to handle searches. An application will supply an implementation
of the SearchSupportFragment.SearchResultProvider
interface to handle the search and return
an ObjectAdapter
containing the results. The results are rendered
into a RowsSupportFragment
, in the same way that they are in a BrowseSupportFragment
.
If you do not supply a callback via
setSpeechRecognitionCallback(SpeechRecognitionCallback)
, an internal speech
recognizer will be used for which your application will need to request
android.permission.RECORD_AUDIO.
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().
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
SearchSupportFragment.SearchResultProvider | Search API to be provided by the application. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Displays the completions shown by the IME.
| |||||||||||
Returns the badge drawable in the search bar.
| |||||||||||
Returns an intent that can be used to request speech recognition.
| |||||||||||
Returns the title set in the search bar.
| |||||||||||
Creates a search fragment with a given search query.
| |||||||||||
Called to do initial creation of a fragment.
| |||||||||||
Called to have the fragment instantiate its user interface view.
| |||||||||||
Called when the fragment is no longer in use.
| |||||||||||
Called when the Fragment is no longer resumed.
| |||||||||||
Called when the fragment is visible to the user and actively running.
| |||||||||||
Called when the Fragment is visible to the user.
| |||||||||||
Sets the badge drawable that will be shown inside the search bar next to
the title.
| |||||||||||
Sets an item clicked listener for the results.
| |||||||||||
Sets an item selection listener for the results.
| |||||||||||
Sets the text of the search query based on the
EXTRA_RESULTS in
the given intent, and optionally submit the query.
| |||||||||||
Sets the text of the search query and optionally submits the query.
| |||||||||||
Sets the search provider that is responsible for returning results for the
search query.
| |||||||||||
Sets this callback to have the fragment pass speech recognition requests
to the activity rather than using an internal recognizer.
| |||||||||||
Sets the title string to be be shown in an empty search bar.
| |||||||||||
Starts speech recognition.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.support.v4.app.Fragment
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.content.ComponentCallbacks
| |||||||||||
From interface
android.view.View.OnCreateContextMenuListener
|
args | Bundle to use for the arguments, if null a new Bundle will be created. |
---|
Displays the completions shown by the IME. An application may provide a list of query completions that the system will show in the IME.
completions | A list of completions to show in the IME. Setting to null or empty will clear the list. |
---|
Returns an intent that can be used to request speech recognition.
Built from the base ACTION_RECOGNIZE_SPEECH
plus
extras:
EXTRA_LANGUAGE_MODEL
set to
LANGUAGE_MODEL_FREE_FORM
EXTRA_PARTIAL_RESULTS
set to trueEXTRA_PROMPT
set to the search bar hint textsetSearchQuery(Intent, boolean)
.
Creates a search fragment with a given search query.
You should only use this if you need to start the search fragment with a pre-filled query.
query | The search query to begin with. |
---|
Called to do initial creation of a fragment. This is called after
onAttach(Activity)
and before
onCreateView(LayoutInflater, ViewGroup, Bundle)
.
Note that this can be called while the fragment's activity is
still in the process of being created. As such, you can not rely
on things like the activity's content view hierarchy being initialized
at this point. If you want to do work once the activity itself is
created, see onActivityCreated(Bundle)
.
savedInstanceState | If the fragment is being re-created from a previous saved state, this is the state. |
---|
Called to have the fragment instantiate its user interface view.
This is optional, and non-graphical fragments can return null (which
is the default implementation). This will be called between
onCreate(Bundle)
and onActivityCreated(Bundle)
.
If you return a View from here, you will later be called in
onDestroyView()
when the view is being released.
inflater | The LayoutInflater object that can be used to inflate any views in the fragment, |
---|---|
container | If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view. |
savedInstanceState | If non-null, this fragment is being re-constructed from a previous saved state as given here. |
Called when the fragment is no longer in use. This is called
after onStop()
and before onDetach()
.
Called when the Fragment is no longer resumed. This is generally
tied to Activity.onPause
of the containing
Activity's lifecycle.
Called when the fragment is visible to the user and actively running.
This is generally
tied to Activity.onResume
of the containing
Activity's lifecycle.
Called when the Fragment is visible to the user. This is generally
tied to Activity.onStart
of the containing
Activity's lifecycle.
Sets the badge drawable that will be shown inside the search bar next to the title.
Sets an item clicked listener for the results.
listener | The item clicked listener to be invoked when an item in the search results is clicked. |
---|
Sets an item selection listener for the results.
listener | The item selection listener to be invoked when an item in the search results is selected. |
---|
Sets the text of the search query based on the EXTRA_RESULTS
in
the given intent, and optionally submit the query. If more than one result is present
in the results list, the first will be used.
intent | Intent received from a speech recognition service. |
---|---|
submit | Whether to submit the query. |
Sets the text of the search query and optionally submits the query. Either
onQueryTextChange
or
onQueryTextSubmit
will be
called on the provider if it is set.
query | The search query to set. |
---|---|
submit | Whether to submit the query. |
Sets the search provider that is responsible for returning results for the search query.
Sets this callback to have the fragment pass speech recognition requests to the activity rather than using an internal recognizer.
Sets the title string to be be shown in an empty search bar. The title may be placed in a call-to-action, such as "Search title" or "Speak to search title".
Starts speech recognition. Typical use case is that activity receives onNewIntent() call when user clicks a MIC button. Note that SearchSupportFragment automatically starts speech recognition at first time created, there is no need to call startRecognition() when fragment is created.