How to get selected chips from ChipGroup?

后端 未结 3 1987
小蘑菇
小蘑菇 2021-01-03 07:43

I search a lot on internet but couldn\'t find the exact solution. Here is the link that i last tried from SO. Get selected Chips from a ChipGroup

I want to get selec

3条回答
  •  伪装坚强ぢ
    2021-01-03 08:13

    I used below mentioned method to detect the selected chips in chipGroup.

    for (chipTitle in stringList) {
        val chip = Chip(chipGroup.context)
        chip.text = chipTitle
        chip.tag = chipTitle
        chip.isClickable = true
        chip.isCheckable = true
        chip.setOnCheckedChangeListener { _, isChecked ->
            if (isChecked){
                Log.e(TAG, chipTitle)
            }
        }
        chipGroup.addView(chip)
    }
    chipGroup.isSingleSelection = true
    

提交回复
热议问题