Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. @BindingAdapter("list", "layout")
  2. fun <T> chips(view: ChipGroup, items: List<T>, layoutId: Int) {
  3. view.removeAllViews()
  4. val inflater = view.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
  5. items.forEachIndexed { index, model ->
  6. val binding = DataBindingUtil.inflate<ViewDataBinding>(inflater, layoutId, view, false)
  7. binding.setVariable(BR.model, model)
  8. (binding.root as Chip).id = index
  9. view.addView(binding.root)
  10. binding.executePendingBindings()
  11. }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement