0
I need to add Chips
Filter type (image below) dynamically
Attempt 1
I tried to create the Chip in a totally dynamic way:
fun onAddChip(name: String){
val chip = Chip(this)
chip.TYPE = Filter //Eu esperava que tivesse como fazer isso
chip.text = name
chip.setTextColor(Color.WHITE)
chip.setChipBackgroundColorResource(R.color.marsala)
chip.chipCornerRadius = 32F
servicos_container_chip_group.addView(chip)
}
But as you can see in the comment on line 4, there is no way to set the Chip type as filter.
Attempt 2
I found here a way to inflate a pre-defined layout, the problem is that I don’t understand what that would be view
that it inserts into the second parameter. I imagine it to be a chip_group
, so I added did as follows:
val chip = layoutInflater.inflate(R.layout.chip_layout, view!!.parent.parent as ViewGroup, false) as Chip
and it didn’t work either. It makes a mistake.
Does anyone have any suggestions?
PS. I hope Maniero does not put my question as out of context, again!