Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

OnSuggestionListener

interface OnSuggestionListener
androidx.appcompat.widget.SearchView.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.