Chip Group OnCheckedChangeListener() not triggered

后端 未结 6 887
遥遥无期
遥遥无期 2020-12-10 05:13

I\'m trying to make a recyclerview filter based ChipGroup & Chip

I\'m use fragment on my app, so, the fragment who contain the RecyclerView contain a fr

6条回答
  •  情歌与酒
    2020-12-10 05:50

    All chips need to have the android:checkable="true" property for the trigger to exist on them.

    In adittion to setting the initial check of any chip (without giving a tap), the order of execution must be first the creation of the listener with chipGroup.setOnCheckedChangeListener() and then chip.isChecked = true.

    So you could handle the checkable property from the xml and isChecked dynamically.

    .xml

    
        
    

    .kt

    binding.chipGroup.setOnCheckedChangeListener { chipGroup, i -> 
    
    }
    binding.firstChip.isChecked = true   //default
    

    GL

提交回复
热议问题