Stay organized with collections
Save and categorize content based on your preferences.
SearchView.OnSuggestionListener
public
static
interface
SearchView.OnSuggestionListener
android.widget.SearchView.OnSuggestionListener
|
Callback interface for selection events on suggestions. These callbacks
are only relevant when a SearchableInfo has been specified by SearchView.setSearchableInfo(SearchableInfo)
.
Summary
Public methods |
abstract
boolean
|
onSuggestionClick(int position)
Called when a suggestion was clicked.
|
abstract
boolean
|
onSuggestionSelect(int position)
Called when a suggestion was selected by navigating to it.
|
Public methods
onSuggestionClick
public abstract boolean onSuggestionClick (int position)
Called when a suggestion was clicked.
Parameters |
position |
int : the absolute position of the clicked item in the list of suggestions. |
Returns |
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
public abstract boolean onSuggestionSelect (int position)
Called when a suggestion was selected by navigating to it.
Parameters |
position |
int : the absolute position in the list of suggestions. |
Returns |
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# SearchView.OnSuggestionListener\n\nAdded in [API level 11](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nSearchView.OnSuggestionListener\n===============================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/widget/SearchView.OnSuggestionListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nSearchView.OnSuggestionListener\n`\n\n\n`\n\n\n`\n\n|------------------------------------------------|\n| android.widget.SearchView.OnSuggestionListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nCallback interface for selection events on suggestions. These callbacks\nare only relevant when a SearchableInfo has been specified by [SearchView.setSearchableInfo(SearchableInfo)](/reference/android/widget/SearchView#setSearchableInfo(android.app.SearchableInfo)).\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[onSuggestionClick](/reference/android/widget/SearchView.OnSuggestionListener#onSuggestionClick(int))`(int position) ` Called when a suggestion was clicked. |\n| ` abstract boolean` | ` `[onSuggestionSelect](/reference/android/widget/SearchView.OnSuggestionListener#onSuggestionSelect(int))`(int position) ` Called when a suggestion was selected by navigating to it. |\n\nPublic methods\n--------------\n\n### onSuggestionClick\n\nAdded in [API level 11](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean onSuggestionClick (int position)\n```\n\nCalled when a suggestion was clicked.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|-------------------------------------------------------------------------------------|\n| `position` | `int`: the absolute position of the clicked item in the list of suggestions. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `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. \u003cbr /\u003e |\n\n### onSuggestionSelect\n\nAdded in [API level 11](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean onSuggestionSelect (int position)\n```\n\nCalled when a suggestion was selected by navigating to it.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|-----------------------------------------------------------------|\n| `position` | `int`: the absolute position in the list of suggestions. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `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. \u003cbr /\u003e |"]]