0

I have a ChipGroup as below :

<com.google.android.material.chip.ChipGroup
                    android:id="@+id/chip_group"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:animationCache="true"
                    android:focusable="true"/>

at first it has no chips inside it, and I filled it with code.

val chipGroup : ChipGroup = findViewById(R.id.chip_group)
for (item in ChipsList)
        {
            val chip = Chip(this)
            chip.text = item
            chip.isCheckable = true
            chip.isCheckedIconVisible = true
            chipGroup.addView(chip)
        }

and it works perfectly.

my question is that, how can I check all of the chips inside the chipGroup with coding? I know that I can clear all checked chips by using chipGroup.clearCheck()

and how can I get all of the chips inside the chipGroup not only checked chips?

SuperStar
  • 41
  • 5

1 Answers1

0

you should just use :

for (item in chipGroup)
                {
                   chipGroup.check(item.id)
                }
SuperStar
  • 41
  • 5