Added in API level 11

SearchView


open class SearchView : LinearLayout, CollapsibleActionView
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.LinearLayout
   ↳ android.widget.SearchView

A widget that provides a user interface for the user to enter a search query and submit a request to a search provider. Shows a list of query suggestions or results, if available, and allows the user to pick a suggestion or result to launch into.

When the SearchView is used in an ActionBar as an action view for a collapsible menu item, it needs to be set to iconified by default using setIconifiedByDefault(true). This is the default, so nothing needs to be done.

If you want the search field to always be visible, then call setIconifiedByDefault(false).

Summary

Nested classes
abstract

abstract

Callbacks for changes to the query text.

abstract

Callback interface for selection events on suggestions.

XML attributes
android:iconifiedByDefault The default state of the SearchView.
android:imeOptions The IME options to set on the query text field.
android:inputType The input type to set on the query text field.
android:maxWidth An optional maximum width of the SearchView.
android:queryHint An optional query hint string to be displayed in the empty query field.
Inherited XML attributes
Inherited constants
Public constructors
SearchView(context: Context!)

SearchView(context: Context!, attrs: AttributeSet!)

SearchView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

SearchView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open CharSequence!

open Int

Returns the IME options set on the query text field.

open Int

Returns the input type set on the query text field.

open Int

Gets the specified maximum width in pixels, if set.

open CharSequence!

Returns the query string currently in the text field.

open CharSequence?

Returns the hint text that will be displayed in the query text field.

open CursorAdapter!

Returns the adapter used for suggestions, if any.

open Boolean

Returns the default iconified state of the search field.

open Boolean

Returns the current iconified state of the SearchView.

open Boolean

Returns the default iconified state of the search field.

open Boolean

Returns whether query refinement is enabled for all items or only specific ones.

open Boolean

Returns whether the submit button is enabled when necessary or never displayed.

open Unit

Called when this view is collapsed as an action view.

open Unit

Called when this view is expanded as an action view.

open Boolean
onKeyDown(keyCode: Int, event: KeyEvent!)

Handles the key down event for dealing with action keys.

open Unit
onWindowFocusChanged(hasWindowFocus: Boolean)

open Unit

Iconifies or expands the SearchView.

open Unit

Sets the default or resting state of the search field.

open Unit
setImeOptions(imeOptions: Int)

Sets the IME options on the query text field.

open Unit
setInputType(inputType: Int)

Sets the input type on the query text field.

open Unit
setMaxWidth(maxpixels: Int)

Makes the view at most this many pixels wide

open Unit

Sets a listener to inform when the user closes the SearchView.

open Unit

Sets a listener to inform when the focus of the query text field changes.

open Unit

Sets a listener for user actions within the SearchView.

open Unit

Sets a listener to inform when the search button is pressed.

open Unit

Sets a listener to inform when a suggestion is focused or clicked.

open Unit
setQuery(query: CharSequence!, submit: Boolean)

Sets a query string in the text field and optionally submits the query as well.

open Unit

Sets the hint text to display in the query text field.

open Unit

Specifies if a query refinement button should be displayed alongside each suggestion or if it should depend on the flags set in the individual items retrieved from the suggestions provider.

open Unit

Sets the SearchableInfo for this SearchView.

open Unit

Enables showing a submit button when the query is non-empty.

open Unit

You can set a custom adapter if you wish.

Protected methods
open Unit

open Unit
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

open Unit

open Parcelable?

Inherited functions
Inherited properties

XML attributes

android:iconifiedByDefault

android:iconifiedByDefault
The default state of the SearchView. If true, it will be iconified when not in use and expanded when clicked.

May be a boolean value, such as "true" or "false".

android:imeOptions

android:imeOptions
The IME options to set on the query text field.

Must be one or more (separated by '|') of the following constant values.

Constant Value Description
actionDone 6 The action key performs a "done" operation, closing the soft input method. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_DONE.
actionGo 2 The action key performs a "go" operation to take the user to the target of the text they typed. Typically used, for example, when entering a URL. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_GO.
actionNext 5 The action key performs a "next" operation, taking the user to the next field that will accept text. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_NEXT.
actionNone 1 This editor has no action associated with it. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_NONE.
actionPrevious 7 The action key performs a "previous" operation, taking the user to the previous field that will accept text. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_PREVIOUS.
actionSearch 3 The action key performs a "search" operation, taking the user to the results of searching for the text the have typed (in whatever context is appropriate). Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_SEARCH.
actionSend 4 The action key performs a "send" operation, delivering the text to its target. This is typically used when composing a message. Corresponds to android.view.inputmethod.EditorInfo#IME_ACTION_SEND.
actionUnspecified 0 There is no specific action associated with this editor, let the editor come up with its own if it can. Corresponds to android.view.inputmethod.EditorInfo#IME_NULL.
flagForceAscii 80000000 Used to request that the IME should be capable of inputting ASCII characters. The intention of this flag is to ensure that the user can type Roman alphabet characters in a android.widget.TextView used for, typically, account ID or password input. It is expected that IMEs normally are able to input ASCII even without being told so (such IMEs already respect this flag in a sense), but there could be some cases they aren't when, for instance, only non-ASCII input languages like Arabic, Greek, Hebrew, Russian are enabled in the IME. Applications need to be aware that the flag is not a guarantee, and not all IMEs will respect it. However, it is strongly recommended for IME authors to respect this flag especially when their IME could end up with a state that has only non-ASCII input languages enabled.

Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_FORCE_ASCII.

flagNavigateNext 8000000 Used to specify that there is something interesting that a forward navigation can focus on. This is like using actionNext, except allows the IME to be multiline (with an enter key) as well as provide forward navigation. Note that some IMEs may not be able to do this, especially when running on a small screen where there is little space. In that case it does not need to present a UI for this option. Like actionNext, if the user selects the IME's facility to forward navigate, this will show up in the application at InputConnection.performEditorAction(int).

Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NAVIGATE_NEXT.

flagNavigatePrevious 4000000 Like flagNavigateNext, but specifies there is something interesting that a backward navigation can focus on. If the user selects the IME's facility to backward navigate, this will show up in the application as an actionPrevious at InputConnection.performEditorAction(int).

Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NAVIGATE_PREVIOUS.

flagNoAccessoryAction 20000000 Used in conjunction with a custom action, this indicates that the action should not be available as an accessory button when the input method is full-screen. Note that by setting this flag, there can be cases where the action is simply never available to the user. Setting this generally means that you think showing text being edited is more important than the action you have supplied.

Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NO_ACCESSORY_ACTION.

flagNoEnterAction 40000000 Used in conjunction with a custom action, this indicates that the action should not be available in-line as a replacement for the "enter" key. Typically this is because the action has such a significant impact or is not recoverable enough that accidentally hitting it should be avoided, such as sending a message. Note that android.widget.TextView will automatically set this flag for you on multi-line text views.

Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION.

flagNoExtractUi 10000000 Used to specify that the IME does not need to show its extracted text UI. For input methods that may be fullscreen, often when in landscape mode, this allows them to be smaller and let part of the application be shown behind. Though there will likely be limited access to the application available from the user, it can make the experience of a (mostly) fullscreen IME less jarring. Note that when this flag is specified the IME may not be set up to be able to display text, so it should only be used in situations where this is not needed.

Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NO_EXTRACT_UI.

flagNoFullscreen 2000000 Used to request that the IME never go into fullscreen mode. Applications need to be aware that the flag is not a guarantee, and not all IMEs will respect it.

Corresponds to android.view.inputmethod.EditorInfo#IME_FLAG_NO_FULLSCREEN.

flagNoPersonalizedLearning 1000000 Used to request that the IME should not update any personalized data such as typing history and personalized language model based on what the user typed on this text editing object. Typical use cases are:
  • When the application is in a special mode, where user's activities are expected to be not recorded in the application's history. Some web browsers and chat applications may have this kind of modes.
  • When storing typing history does not make much sense. Specifying this flag in typing games may help to avoid typing history from being filled up with words that the user is less likely to type in their daily life. Another example is that when the application already knows that the expected input is not a valid word (e.g. a promotion code that is not a valid word in any natural language).

Applications need to be aware that the flag is not a guarantee, and some IMEs may not respect it.

normal 0 There are no special semantics associated with this editor.

android:inputType

android:inputType
The input type to set on the query text field.

Must be one or more (separated by '|') of the following constant values.

Constant Value Description
date 14 For entering a date. Corresponds to android.text.InputType#TYPE_CLASS_DATETIME | android.text.InputType#TYPE_DATETIME_VARIATION_DATE.
datetime 4 For entering a date and time. Corresponds to android.text.InputType#TYPE_CLASS_DATETIME | android.text.InputType#TYPE_DATETIME_VARIATION_NORMAL.
none 0 There is no content type. The text is not editable.
number 2 A numeric only field. Corresponds to android.text.InputType#TYPE_CLASS_NUMBER | android.text.InputType#TYPE_NUMBER_VARIATION_NORMAL.
numberDecimal 2002 Can be combined with number and its other options to allow a decimal (fractional) number. Corresponds to android.text.InputType#TYPE_CLASS_NUMBER | android.text.InputType#TYPE_NUMBER_FLAG_DECIMAL.
numberPassword 12 A numeric password field. Corresponds to android.text.InputType#TYPE_CLASS_NUMBER | android.text.InputType#TYPE_NUMBER_VARIATION_PASSWORD.
numberSigned 1002 Can be combined with number and its other options to allow a signed number. Corresponds to android.text.InputType#TYPE_CLASS_NUMBER | android.text.InputType#TYPE_NUMBER_FLAG_SIGNED.
phone 3 For entering a phone number. Corresponds to android.text.InputType#TYPE_CLASS_PHONE.
text 1 Just plain old text. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_NORMAL.
textAutoComplete 10001 Can be combined with text and its variations to specify that this field will be doing its own auto-completion and talking with the input method appropriately. Corresponds to android.text.InputType#TYPE_TEXT_FLAG_AUTO_COMPLETE.
textAutoCorrect 8001 Can be combined with text and its variations to request auto-correction of text being input. Corresponds to android.text.InputType#TYPE_TEXT_FLAG_AUTO_CORRECT.
textCapCharacters 1001 Can be combined with text and its variations to request capitalization of all characters. Corresponds to android.text.InputType#TYPE_TEXT_FLAG_CAP_CHARACTERS.
textCapSentences 4001 Can be combined with text and its variations to request capitalization of the first character of every sentence. Corresponds to android.text.InputType#TYPE_TEXT_FLAG_CAP_SENTENCES.
textCapWords 2001 Can be combined with text and its variations to request capitalization of the first character of every word. Corresponds to android.text.InputType#TYPE_TEXT_FLAG_CAP_WORDS.
textEmailAddress 21 Text that will be used as an e-mail address. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_EMAIL_ADDRESS.
textEmailSubject 31 Text that is being supplied as the subject of an e-mail. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_EMAIL_SUBJECT.
textEnableTextConversionSuggestions 100001 Can be combined with text and its variations to indicate that if there is extra information, the IME should provide android.view.inputmethod.TextAttribute. Corresponds to android.text.InputType#TYPE_TEXT_FLAG_ENABLE_TEXT_CONVERSION_SUGGESTIONS.
textFilter b1 Text that is filtering some other data. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_FILTER.
textImeMultiLine 40001 Can be combined with text and its variations to indicate that though the regular text view should not be multiple lines, the IME should provide multiple lines if it can. Corresponds to android.text.InputType#TYPE_TEXT_FLAG_IME_MULTI_LINE.
textLongMessage 51 Text that is the content of a long message. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_LONG_MESSAGE.
textMultiLine 20001 Can be combined with text and its variations to allow multiple lines of text in the field. If this flag is not set, the text field will be constrained to a single line. Corresponds to android.text.InputType#TYPE_TEXT_FLAG_MULTI_LINE. Note: If this flag is not set and the text field doesn't have max length limit, the framework automatically set maximum length of the characters to 5000 for the performance reasons.
textNoSuggestions 80001 Can be combined with text and its variations to indicate that the IME should not show any dictionary-based word suggestions. Corresponds to android.text.InputType#TYPE_TEXT_FLAG_NO_SUGGESTIONS.
textPassword 81 Text that is a password. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_PASSWORD.
textPersonName 61 Text that is the name of a person. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_PERSON_NAME.
textPhonetic c1 Text that is for phonetic pronunciation, such as a phonetic name field in a contact entry. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_PHONETIC.
textPostalAddress 71 Text that is being supplied as a postal mailing address. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_POSTAL_ADDRESS.
textShortMessage 41 Text that is the content of a short message. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_SHORT_MESSAGE.
textUri 11 Text that will be used as a URI. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_URI.
textVisiblePassword 91 Text that is a password that should be visible. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_VISIBLE_PASSWORD.
textWebEditText a1 Text that is being supplied as text in a web form. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_WEB_EDIT_TEXT.
textWebEmailAddress d1 Text that will be used as an e-mail address on a web form. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS.
textWebPassword e1 Text that will be used as a password on a web form. Corresponds to android.text.InputType#TYPE_CLASS_TEXT | android.text.InputType#TYPE_TEXT_VARIATION_WEB_PASSWORD.
time 24 For entering a time. Corresponds to android.text.InputType#TYPE_CLASS_DATETIME | android.text.InputType#TYPE_DATETIME_VARIATION_TIME.

android:maxWidth

android:maxWidth
An optional maximum width of the SearchView.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

android:queryHint

android:queryHint
An optional query hint string to be displayed in the empty query field.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Public constructors

SearchView

Added in API level 11
SearchView(context: Context!)

SearchView

Added in API level 11
SearchView(
    context: Context!,
    attrs: AttributeSet!)

SearchView

Added in API level 21
SearchView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

SearchView

Added in API level 21
SearchView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

getImeOptions

Added in API level 16
open fun getImeOptions(): Int

Returns the IME options set on the query text field.

Return
Int the ime options

getInputType

Added in API level 16
open fun getInputType(): Int

Returns the input type set on the query text field.

Return
Int the input type

getMaxWidth

Added in API level 16
open fun getMaxWidth(): Int

Gets the specified maximum width in pixels, if set. Returns zero if no maximum width was specified.

Return
Int the maximum width of the view

getQuery

Added in API level 11
open fun getQuery(): CharSequence!

Returns the query string currently in the text field.

Return
CharSequence! the query string

getQueryHint

Added in API level 16
open fun getQueryHint(): CharSequence?

Returns the hint text that will be displayed in the query text field.

The displayed query hint is chosen in the following order:

  1. Non-null value set with setQueryHint(java.lang.CharSequence)
  2. Value specified in XML using android:queryHint
  3. Valid string resource ID exposed by the SearchableInfo via SearchableInfo#getHintId()
  4. Default hint provided by the theme against which the view was inflated
Return
CharSequence? the displayed query hint text, or null if none set

getSuggestionsAdapter

Added in API level 11
open fun getSuggestionsAdapter(): CursorAdapter!

Returns the adapter used for suggestions, if any.

Return
CursorAdapter! the suggestions adapter

isIconfiedByDefault

Added in API level 11
Deprecated in API level 29
open fun isIconfiedByDefault(): Boolean

Deprecated: use isIconifiedByDefault()

Returns the default iconified state of the search field.

Return
Boolean

isIconified

Added in API level 11
open fun isIconified(): Boolean

Returns the current iconified state of the SearchView.

Return
Boolean true if the SearchView is currently iconified, false if the search field is fully visible.

isIconifiedByDefault

Added in API level 29
open fun isIconifiedByDefault(): Boolean

Returns the default iconified state of the search field.

isQueryRefinementEnabled

Added in API level 11
open fun isQueryRefinementEnabled(): Boolean

Returns whether query refinement is enabled for all items or only specific ones.

Return
Boolean true if enabled for all items, false otherwise.

isSubmitButtonEnabled

Added in API level 11
open fun isSubmitButtonEnabled(): Boolean

Returns whether the submit button is enabled when necessary or never displayed.

Return
Boolean whether the submit button is enabled automatically when necessary

onActionViewCollapsed

Added in API level 14
open fun onActionViewCollapsed(): Unit

Called when this view is collapsed as an action view. See MenuItem#collapseActionView().

onActionViewExpanded

Added in API level 14
open fun onActionViewExpanded(): Unit

Called when this view is expanded as an action view. See MenuItem#expandActionView().

onKeyDown

Added in API level 11
open fun onKeyDown(
    keyCode: Int,
    event: KeyEvent!
): Boolean

Handles the key down event for dealing with action keys.

Parameters
keyCode Int: This is the keycode of the typed key, and is the same value as found in the KeyEvent parameter.
event KeyEvent!: The complete event record for the typed key
Return
Boolean true if the event was handled here, or false if not.

onWindowFocusChanged

Added in API level 11
open fun onWindowFocusChanged(hasWindowFocus: Boolean): Unit
Parameters
hasWindowFocus Boolean: True if the window containing this view now has focus, false otherwise.

setIconified

Added in API level 11
open fun setIconified(iconify: Boolean): Unit

Iconifies or expands the SearchView. Any query text is cleared when iconified. This is a temporary state and does not override the default iconified state set by setIconifiedByDefault(boolean). If the default state is iconified, then a false here will only be valid until the user closes the field. And if the default state is expanded, then a true here will only clear the text field and not close it.

Parameters
iconify Boolean: a true value will collapse the SearchView to an icon, while a false will expand it.

setIconifiedByDefault

Added in API level 11
open fun setIconifiedByDefault(iconified: Boolean): Unit

Sets the default or resting state of the search field. If true, a single search icon is shown by default and expands to show the text field and other buttons when pressed. Also, if the default state is iconified, then it collapses to that state when the close button is pressed. Changes to this property will take effect immediately.

The default value is true.

Parameters
iconified Boolean: whether the search field should be iconified by default

setImeOptions

Added in API level 14
open fun setImeOptions(imeOptions: Int): Unit

Sets the IME options on the query text field.

Parameters
imeOptions Int: the options to set on the query text field

setInputType

Added in API level 14
open fun setInputType(inputType: Int): Unit

Sets the input type on the query text field.

Parameters
inputType Int: the input type to set on the query text field

setMaxWidth

Added in API level 11
open fun setMaxWidth(maxpixels: Int): Unit

Makes the view at most this many pixels wide

setOnCloseListener

Added in API level 11
open fun setOnCloseListener(listener: SearchView.OnCloseListener!): Unit

Sets a listener to inform when the user closes the SearchView.

Parameters
listener SearchView.OnCloseListener!: the listener to call when the user closes the SearchView.

setOnQueryTextFocusChangeListener

Added in API level 11
open fun setOnQueryTextFocusChangeListener(listener: View.OnFocusChangeListener!): Unit

Sets a listener to inform when the focus of the query text field changes.

Parameters
listener View.OnFocusChangeListener!: the listener to inform of focus changes.

setOnQueryTextListener

Added in API level 11
open fun setOnQueryTextListener(listener: SearchView.OnQueryTextListener!): Unit

Sets a listener for user actions within the SearchView.

Parameters
listener SearchView.OnQueryTextListener!: the listener object that receives callbacks when the user performs actions in the SearchView such as clicking on buttons or typing a query.

setOnSearchClickListener

Added in API level 11
open fun setOnSearchClickListener(listener: View.OnClickListener!): Unit

Sets a listener to inform when the search button is pressed. This is only relevant when the text field is not visible by default. Calling setIconified(false) can also cause this listener to be informed.

Parameters
listener View.OnClickListener!: the listener to inform when the search button is clicked or the text field is programmatically de-iconified.

setOnSuggestionListener

Added in API level 11
open fun setOnSuggestionListener(listener: SearchView.OnSuggestionListener!): Unit

Sets a listener to inform when a suggestion is focused or clicked.

Parameters
listener SearchView.OnSuggestionListener!: the listener to inform of suggestion selection events.

setQuery

Added in API level 11
open fun setQuery(
    query: CharSequence!,
    submit: Boolean
): Unit

Sets a query string in the text field and optionally submits the query as well.

Parameters
query CharSequence!: the query string. This replaces any query text already present in the text field.
submit Boolean: whether to submit the query right now or only update the contents of text field.

setQueryHint

Added in API level 11
open fun setQueryHint(hint: CharSequence?): Unit

Sets the hint text to display in the query text field. This overrides any hint specified in the SearchableInfo.

This value may be specified as an empty string to prevent any query hint from being displayed.

Parameters
hint CharSequence?: the hint text to display or null to clear

setQueryRefinementEnabled

Added in API level 11
open fun setQueryRefinementEnabled(enable: Boolean): Unit

Specifies if a query refinement button should be displayed alongside each suggestion or if it should depend on the flags set in the individual items retrieved from the suggestions provider. Clicking on the query refinement button will replace the text in the query text field with the text from the suggestion. This flag only takes effect if a SearchableInfo has been specified with setSearchableInfo(android.app.SearchableInfo) and not when using a custom adapter.

Parameters
enable Boolean: true if all items should have a query refinement button, false if only those items that have a query refinement flag set should have the button.

setSearchableInfo

Added in API level 11
open fun setSearchableInfo(searchable: SearchableInfo!): Unit

Sets the SearchableInfo for this SearchView. Properties in the SearchableInfo are used to display labels, hints, suggestions, create intents for launching search results screens and controlling other affordances such as a voice button.

Parameters
searchable SearchableInfo!: a SearchableInfo can be retrieved from the SearchManager, for a specific activity or a global search provider.

setSubmitButtonEnabled

Added in API level 11
open fun setSubmitButtonEnabled(enabled: Boolean): Unit

Enables showing a submit button when the query is non-empty. In cases where the SearchView is being used to filter the contents of the current activity and doesn't launch a separate results activity, then the submit button should be disabled.

Parameters
enabled Boolean: true to show a submit button for submitting queries, false if a submit button is not required.

setSuggestionsAdapter

Added in API level 11
open fun setSuggestionsAdapter(adapter: CursorAdapter!): Unit

You can set a custom adapter if you wish. Otherwise the default adapter is used to display the suggestions from the suggestions provider associated with the SearchableInfo.

Protected methods

onDetachedFromWindow

Added in API level 11
protected open fun onDetachedFromWindow(): Unit

onLayout

Added in API level 11
protected open fun onLayout(
    changed: Boolean,
    left: Int,
    top: Int,
    right: Int,
    bottom: Int
): Unit
Parameters
changed Boolean: This is a new size or position for this view
left Int: Left position, relative to parent
top Int: Top position, relative to parent
right Int: Right position, relative to parent
bottom Int: Bottom position, relative to parent

onMeasure

Added in API level 11
protected open fun onMeasure(
    widthMeasureSpec: Int,
    heightMeasureSpec: Int
): Unit
Parameters
widthMeasureSpec Int: horizontal space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.
heightMeasureSpec Int: vertical space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.

onRestoreInstanceState

Added in API level 11
protected open fun onRestoreInstanceState(state: Parcelable!): Unit
Parameters
state Parcelable!: The frozen state that had previously been returned by onSaveInstanceState.

onSaveInstanceState

Added in API level 11
protected open fun onSaveInstanceState(): Parcelable?
Return
Parcelable? Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save.