Kishan sharma
Kishan sharma

Reputation: 741

Can't able to add whole arrayList to ChipGroup

I am working on an application where I need to show multiple chips from the ArrayList.

Please consider the following code:

<android.support.design.chip.ChipGroup
     android:id="@+id/chipGroupProfCreds"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:minHeight="@dimen/_50sdp"/>

Java

Chip lChip = new Chip(SignUpNextActivity.this);
for (int i = 0; i < Constant.arraylistselectedproffesionalcredential.size(); i++) {
    lChip.setText(Constant.arraylistselectedproffesionalcredential.get(i).toString());
    binding.chipGroupProfCreds.addView(lChip);
}

enter image description here

Can you please let me know how can I add the whole Constant.arraylistselectedproffesionalcredential to this ChipGroup.

Upvotes: 3

Views: 416

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363895

You can use something like:

  for (String chipText: Constant.arraylistselectedproffesionalcredential){
    Chip lChip = new Chip(this);
    lChip.setText(chipText);
    ....
    chipGroup.addView(lChip);
  }

Upvotes: 2

Related Questions