如何通过edittext的文本观察器过滤列表视图?

问题描述

我正在通过 edittext 的文本观察器过滤列表视图,但我之所以这么问是因为它没有被过滤。 这就是主要活动的样子。

 val lv = binding.lvMainMusic
 val sb = binding.searchMusic
  lv.isTextFilterEnabled = true
    sb.addTextChangedListener(object:TextWatcher{
        override fun beforeTextChanged(s: CharSequence?,start: Int,count: Int,after: Int) {
        }

        override fun onTextChanged(s: CharSequence?,before: Int,count: Int) {
            lv.setFilterText(sb.text.toString())

        }

        override fun afterTextChanged(s: Editable?) {
            if(sb.text.isEmpty()){
                lv.clearTextFilter()
            }
        }

    })

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)