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
It works like this way.
// com.google.android.material.chip.ChipGroup
app:singleSelection="true"
// com.google.android.material.chip.Chip (R.layout.chip)
style="@style/Widget.MaterialComponents.Chip.Choice"
// Inflate instead of NEW instance
val chip = layoutInflater.inflate(R.layout.chip, chipGroup, false) as Chip
chip.text = "Text"
chipGroup.addView(chip)
// setOnCheckedChangeListener
chipGroup.setOnCheckedChangeListener { group, checkedId ->
// The same checked chip
if (checkedId == -1) {
return@setOnCheckedChangeListener
}
// TODO
}