How to get selected chips from ChipGroup?

后端 未结 3 2000
小蘑菇
小蘑菇 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

    Starting with the version 1.2.0 you can use the method chipGroup.getCheckedChipIds()

    List ids = chipGroup.getCheckedChipIds();
    for (Integer id:ids){
          Chip chip = chipGroup.findViewById(id);
          //....
    }
    

    OLD ANSWER with 1.1.0:

    currently there isn't a direct API to get the selected chips.
    However you can iterate through the children of the ChipGroup and check chip.isChecked().

       ChipGroup chipGroup = findViewById(R.id.....);
       for (int i=0; i

提交回复
热议问题