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