SearchBar
class SearchBar : RelativeLayout
| kotlin.Any | ||||
| ↳ | android.view.View | |||
| ↳ | android.view.ViewGroup | |||
| ↳ | android.widget.RelativeLayout | |||
| ↳ | androidx.leanback.widget.SearchBar |
A search widget containing a search orb and a text entry view.
Note: When SpeechRecognitionCallback is not used, i.e. using SpeechRecognizer, your application will need to declare android.permission.RECORD_AUDIO in manifest file. If your application target >= 23 and the device is running >= 23, it needs implement SearchBarPermissionListener where requests runtime permission.
Summary
Nested types |
|---|
interface SearchBar.SearchBarListenerInterface for receiving notification of search query changes. |
interface SearchBar.SearchBarPermissionListenerInterface that handles runtime permissions requests. |
Public constructors |
|---|
SearchBar(context: Context!, attrs: AttributeSet!) |
SearchBar(context: Context!, attrs: AttributeSet!, defStyle: Int) |
Public functions |
|
|---|---|
Unit |
displayCompletions(completions: Array<CompletionInfo!>!)Updates the completion list shown by the IME |
Unit |
displayCompletions(completions: (Mutable)List<String!>!)Updates the completion list shown by the IME |
Drawable! |
Returns the badge drawable |
CharSequence! |
getHint()Returns the current search bar hint text. |
String! |
getTitle()Returns the current title |
Boolean |
Returns true if is not running Recognizer, false otherwise. |
Unit |
setBadgeDrawable(drawable: Drawable!)Sets the badge drawable showing inside the search bar. |
Unit |
setNextFocusDownId(viewId: Int) |
Unit |
Sets listener that handles runtime permission requests. |
Unit |
Sets background color of not-listening state search orb. |
Unit |
Sets background color of listening state search orb. |
Unit |
setSearchBarListener(listener: SearchBar.SearchBarListener!)Sets a listener for when the term search changes |
Unit |
setSearchQuery(query: String!)Sets the search query |
Unit |
This function is deprecated. Launching voice recognition activity is no longer supported. |
Unit |
setSpeechRecognizer(recognizer: SpeechRecognizer!)Sets the speech recognizer to be used when doing voice search. |
Unit |
Sets the title text used in the hint shown in the search bar. |
Unit |
|
Unit |
Stops the speech recognition, if already started. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Public functions
displayCompletions
fun displayCompletions(completions: Array<CompletionInfo!>!): Unit
Updates the completion list shown by the IME
| Parameters | |
|---|---|
completions: Array<CompletionInfo!>! |
list of completions shown in the IME, can be null or empty to clear them |
displayCompletions
fun displayCompletions(completions: (Mutable)List<String!>!): Unit
Updates the completion list shown by the IME
isRecognizing
fun isRecognizing(): Boolean
Returns true if is not running Recognizer, false otherwise.
| Returns | |
|---|---|
Boolean |
True if is not running Recognizer, false otherwise. |
setBadgeDrawable
fun setBadgeDrawable(drawable: Drawable!): Unit
Sets the badge drawable showing inside the search bar.
| Parameters | |
|---|---|
drawable: Drawable! |
The drawable to be used in the search bar. |
setPermissionListener
fun setPermissionListener(listener: SearchBar.SearchBarPermissionListener!): Unit
Sets listener that handles runtime permission requests.
| Parameters | |
|---|---|
listener: SearchBar.SearchBarPermissionListener! |
Listener that handles runtime permission requests. |
setSearchAffordanceColors
fun setSearchAffordanceColors(colors: SearchOrbView.Colors!): Unit
Sets background color of not-listening state search orb.
| Parameters | |
|---|---|
colors: SearchOrbView.Colors! |
SearchOrbView.Colors. |
setSearchAffordanceColorsInListening
fun setSearchAffordanceColorsInListening(colors: SearchOrbView.Colors!): Unit
Sets background color of listening state search orb.
| Parameters | |
|---|---|
colors: SearchOrbView.Colors! |
SearchOrbView.Colors. |
setSearchBarListener
fun setSearchBarListener(listener: SearchBar.SearchBarListener!): Unit
Sets a listener for when the term search changes
| Parameters | |
|---|---|
listener: SearchBar.SearchBarListener! |
setSearchQuery
fun setSearchQuery(query: String!): Unit
Sets the search query
| Parameters | |
|---|---|
query: String! |
the search query to use |
funsetSpeechRecognitionCallback(request: SpeechRecognitionCallback!): Unit
Sets the speech recognition callback.
setSpeechRecognizer
fun setSpeechRecognizer(recognizer: SpeechRecognizer!): Unit
Sets the speech recognizer to be used when doing voice search. The Activity/Fragment is in charge of creating and destroying the recognizer with its own lifecycle.
| Parameters | |
|---|---|
recognizer: SpeechRecognizer! |
a SpeechRecognizer |
setTitle
fun setTitle(title: String!): Unit
Sets the title text used in the hint shown in the search bar.
| Parameters | |
|---|---|
title: String! |
The hint to use. |
stopRecognition
fun stopRecognition(): Unit
Stops the speech recognition, if already started.