我在 android、eclipse Scala 插件中使用了 searchView 小部件,我想在按下搜索按钮后更新我的列表,现在我的过滤方法实现中有一些错误
请你给我一些提示,
这是过滤方法:
override def getFilter(): Filter = {
new Filter() {
protected override def publishResults(constraint: CharSequence, results:
FilterResults) {
books = results.values.asInstanceOf[List[BookMetadata]]
ItemAdapter.this.notifyDataSetChanged()
}
protected override def performFiltering(constraint: CharSequence): FilterResults = {
val filteredResults: List[BookMetadata] =
ListBuffer(books.asScala.toList.filter(b.startsWith(constraint.toString)): _*)
val results = new FilterResults()
results.values = filteredResults
results
}
}
}
我在这里有一个错误:
书籍 = results.values.asInstanceOf[List[BookMetadata]]
error: Multiple markers at this
line
- reassignment to val
- reassignment to val
b的一个错误。val filtersResults: List[BookMetadata] =
ListBuffer(books.asScala.toList.filter(b.startsWith(constraint.toString)): _*)
not found: value
b
提前致谢!