Last active
August 15, 2019 09:42
-
-
Save yashprakash13/677fec78032ff9ab352689c972ebacff to your computer and use it in GitHub Desktop.
onCreateMenu For Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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