MaterialSearchBar icon indicating copy to clipboard operation
MaterialSearchBar copied to clipboard

My suggestion are not comming

Open lisumac opened this issue 6 years ago • 1 comments

how to make clickable the search suggestion list

lisumac avatar Mar 12 '19 06:03 lisumac

You can use the following method :

searchBar.setSuggestionsClickListener(object : SuggestionsAdapter.OnItemViewClickListener {
            override fun OnItemDeleteListener(position: Int, v: View?) { 
                  //on item cleared
             }
            override fun OnItemClickListener(position: Int, v: View?) {
                //on item clicked
            }})

Note that item clicks do not dismiss the suggestion list, in order to do that, you can use the following methods :

searchBar.hideSuggestionsList() -> To hide the suggestions list searchBar.text = searchBar.lastSuggestions[position].toString() -> To move suggestion item's text to the search bar text field listener.onTextChanged(searchBar.text) -> using an interface or something similar, you can start searching instantly after suggestion item was clicked.

Note that implementing suggestion item click listener will disable automatic item clearing on clear button click, you can use the following method :

val newList = searchBar.lastSuggestions ; newList.removeAt(position) -> create a list of the old suggestions and remove the deleted item searchBar.updateLastSuggestions(newList) -> notify the list

tamimattafi avatar Mar 25 '19 16:03 tamimattafi