Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. val tags = listOf(
  2. "John Smith",
  3. "Kate Eckhart",
  4. "Emily Sun",
  5. "Frodo Baggins",
  6. "Yanay Zabary",
  7. "Sze Lok Ho",
  8. "Jesse Albright",
  9. "Shayna something",
  10. "Makena Lawrence"
  11. )
  12.  
  13. questionTagsInput.addTextChangedListener(object : TextWatcher {
  14. override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
  15.  
  16. val userInput = s.toString()
  17.  
  18. if (userInput == "") {
  19. tagSuggestionRecycler.visibility = View.GONE
  20. tagsFiltredAdapter.clear()
  21.  
  22.  
  23. } else {
  24. val relevantTags: List<String> = tags.filter { it.contains(userInput) }
  25.  
  26. for (t in relevantTags) {
  27. tagSuggestionRecycler.visibility = View.VISIBLE
  28. tagsFiltredAdapter.add(SingleTagSuggestion(t))
  29. }
  30.  
  31. }
  32.  
  33. }
  34.  
  35.  
  36. override fun afterTextChanged(s: Editable?) {
  37. }
  38.  
  39. override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
  40. }
  41.  
  42. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement