展开式列表视图组点击会覆盖组的打开

时间:2019-06-01 19:41:43

标签: android

我想在用户单击它时更改可扩展listView组上的箭头图标,所以我添加了代码

override fun getGroupView(groupPosition: Int, isExpanded: Boolean, view: View?, parent: ViewGroup?): View {
    val itemGroup = getGroup(groupPosition)

    var convertView = view

    if (convertView == null) {
        val layoutInflater = parent?.context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
        convertView = layoutInflater.inflate(R.layout.list_of_services_group, null)
    }

    val titleView = convertView!!.findViewById(R.id.list_of_services_group_title) as TextView
    titleView.text = itemGroup.name

    val arrow = convertView.findViewById(R.id.list_of_services_group_arrow) as ImageView

    convertView.onClick {
        if (openedMap[groupPosition] == false) {
            arrow.imageResource = R.drawable.arrow_up
            openedMap[groupPosition] = true
        } else {
            arrow.imageResource = R.drawable.arrow_down
            openedMap[groupPosition] = false
        }
    }

    return convertView
}

但是,当我添加convertView.onClick组已停止打开组时,它现在仅处理箭头更改。如何在此组中添加扩展/冷备份?

0 个答案:

没有答案