我想在带有Room db的回收者视图列表中进行搜索。在mhetod setAll中,我在列表的arraylist中设置了此值一次设置的一些值(我调试)
internal fun setAll(productEntity: List<ProductEntity>) {
this.filterListResult = productEntity
lists.addAll(filterListResult)
notifyDataSetChanged()
搜索后此列表为空
override fun getFilter(): Filter {
return object : Filter() {
override fun performFiltering(constraint: CharSequence?): FilterResults {
val charSearch = constraint.toString()
if (charSearch.isEmpty())
filterListResult = productsList
else {
val resultList= ArrayList<ProductEntity>()
lists.size
for (row in lists){
if(row.productName.toLowerCase().contains(charSearch.toLowerCase()))
resultList.add(row)
}
filterListResult = resultList