Stay organized with collections
Save and categorize content based on your preferences.
OnSuggestionListener
interface OnSuggestionListener
Callback interface for selection events on suggestions. These callbacks are only relevant when a SearchableInfo has been specified by setSearchableInfo
.
Summary
Public methods |
abstract Boolean |
Called when a suggestion was clicked.
|
abstract Boolean |
Called when a suggestion was selected by navigating to it.
|
Public methods
onSuggestionClick
abstract fun onSuggestionClick(position: Int): Boolean
Called when a suggestion was clicked.
Parameters |
position |
Int: the absolute position of the clicked item in the list of suggestions. |
Return |
Boolean |
true if the listener handles the event and wants to override the default behavior of launching any intent or submitting a search query specified on that item. Return false otherwise. |
onSuggestionSelect
abstract fun onSuggestionSelect(position: Int): Boolean
Called when a suggestion was selected by navigating to it.
Parameters |
position |
Int: the absolute position in the list of suggestions. |
Return |
Boolean |
true if the listener handles the event and wants to override the default behavior of possibly rewriting the query based on the selected item, false otherwise. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# SearchView.OnSuggestionListener\n\nAdded in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnSuggestionListener\n====================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/widget/SearchView.OnSuggestionListener \"View this page in Java\") \n\n```\ninterface OnSuggestionListener\n```\n\n|-----------------------------------------------------|\n| [android.widget.SearchView.OnSuggestionListener](#) |\n\nCallback interface for selection events on suggestions. These callbacks are only relevant when a SearchableInfo has been specified by [setSearchableInfo](/reference/kotlin/android/widget/SearchView#setSearchableInfo(android.app.SearchableInfo)).\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onSuggestionClick](#onSuggestionClick(kotlin.Int))`(`position:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when a suggestion was clicked. |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onSuggestionSelect](#onSuggestionSelect(kotlin.Int))`(`position:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when a suggestion was selected by navigating to it. |\n\nPublic methods\n--------------\n\n### onSuggestionClick\n\nAdded in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onSuggestionClick(position: Int): Boolean\n```\n\nCalled when a suggestion was clicked.\n\n| Parameters ||\n|------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| `position` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the absolute position of the clicked item in the list of suggestions. |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if the listener handles the event and wants to override the default behavior of launching any intent or submitting a search query specified on that item. Return false otherwise. |\n\n### onSuggestionSelect\n\nAdded in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onSuggestionSelect(position: Int): Boolean\n```\n\nCalled when a suggestion was selected by navigating to it.\n\n| Parameters ||\n|------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `position` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the absolute position in the list of suggestions. |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if the listener handles the event and wants to override the default behavior of possibly rewriting the query based on the selected item, false otherwise. |"]]