Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val tags = listOf(
- "John Smith",
- "Kate Eckhart",
- "Emily Sun",
- "Frodo Baggins",
- "Yanay Zabary",
- "Sze Lok Ho",
- "Jesse Albright",
- "Shayna something",
- "Makena Lawrence"
- )
- questionTagsInput.addTextChangedListener(object : TextWatcher {
- override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
- val userInput = s.toString()
- if (userInput == "") {
- tagSuggestionRecycler.visibility = View.GONE
- tagsFiltredAdapter.clear()
- } else {
- val relevantTags: List<String> = tags.filter { it.contains(userInput) }
- for (t in relevantTags) {
- tagSuggestionRecycler.visibility = View.VISIBLE
- tagsFiltredAdapter.add(SingleTagSuggestion(t))
- }
- }
- }
- override fun afterTextChanged(s: Editable?) {
- }
- override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement