Skip to content

Instantly share code, notes, and snippets.

@yashprakash13
Last active August 15, 2019 09:42
Show Gist options
  • Save yashprakash13/677fec78032ff9ab352689c972ebacff to your computer and use it in GitHub Desktop.
Save yashprakash13/677fec78032ff9ab352689c972ebacff to your computer and use it in GitHub Desktop.
onCreateMenu For Search
val search = menu.findItem(R.id.searchItems)
searchView = search.actionView as androidx.appcompat.widget.SearchView
searchView.isSubmitButtonEnabled = true
searchView.setOnQueryTextListener(object: androidx.appcompat.widget.
SearchView.OnQueryTextListener{
override fun onQueryTextSubmit(query: String?): Boolean {
if (query != null) {
getItemsFromDb(query)
}
return true
}
override fun onQueryTextChange(newText: String?): Boolean {
if (newText != null) {
getItemsFromDb(newText)
}
return true
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment