Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @BindingAdapter("list", "layout")
- fun <T> chips(view: ChipGroup, items: List<T>, layoutId: Int) {
- view.removeAllViews()
- val inflater = view.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
- items.forEachIndexed { index, model ->
- val binding = DataBindingUtil.inflate<ViewDataBinding>(inflater, layoutId, view, false)
- binding.setVariable(BR.model, model)
- (binding.root as Chip).id = index
- view.addView(binding.root)
- binding.executePendingBindings()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement