ExpandableRecyclerAdapter过滤器不正确

时间:2019-02-15 15:05:59

标签: android filter expandablerecyclerview

我有ExpandableRecyclerAdapter具有这样的标题列表和子列表标题类

class Recipe(val name: String, private val mIngredients: ArrayList<RestoranItem>) : Parent<RestoranItem> {

override fun getChildList(): ArrayList<RestoranItem> {
    return mIngredients
}

override fun isInitiallyExpanded(): Boolean {
    return false
}

}

和我的过滤器

fun filter(charText: String) {
    var charText = charText

    charText = charText.toLowerCase(Locale.getDefault())

    copyFeed= ArrayList<RestoranItem>()
    mRecipeList.clear()

    if (charText.isEmpty()) {
        mRecipeList.addAll(restoranlist)

    } else {
        for ((it,feedItem) in restoranlist.withIndex()) {

            for ((index,item) in restoranlist[it].childList.withIndex()) {

                if (item.text1!!.toLowerCase(Locale.getDefault()).contains(charText) || item.text6!!.toLowerCase(Locale.getDefault()).contains(charText)) {

                    mRecipeList.add(feedItem)
                }

            }


        }
    }

    notifyParentDataSetChanged(true)

}

restoranlist是我的同伴静态arraylist实际上是mRecipeList数组的副本

这无法正常工作,我该如何自定义您可以帮助我?

0 个答案:

没有答案