# SearchView.OnSuggestionListener

Artifact: [androidx.appcompat:appcompat](https://developer.android.com/jetpack/androidx/releases/appcompat) [View Source](https://cs.android.com/search?q=file:androidx/appcompat/widget/SearchView.java+class:androidx.appcompat.widget.SearchView.OnSuggestionListener) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

*** ** * ** ***


```
interface SearchView.OnSuggestionListener
```

<br />

*** ** * ** ***

Callback interface for selection events on suggestions. These callbacks are only relevant when a SearchableInfo has been specified by `https://developer.android.com/reference/kotlin/androidx/appcompat/widget/SearchView#setSearchableInfo(android.app.SearchableInfo)`.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/widget/SearchView.OnSuggestionListener#onSuggestionClick(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Called when a suggestion was clicked. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/widget/SearchView.OnSuggestionListener#onSuggestionSelect(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Called when a suggestion was selected by navigating to it. |

## Public functions

### onSuggestionClick

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun onSuggestionClick(position: Int): Boolean
```

Called when a suggestion was clicked.

| Parameters |
|---|---|
| `position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the absolute position of the clicked item in the list of suggestions. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-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. |

### onSuggestionSelect

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun onSuggestionSelect(position: Int): Boolean
```

Called when a suggestion was selected by navigating to it.

| Parameters |
|---|---|
| `position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the absolute position in the list of suggestions. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-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. |