SHARE
TWEET

Untitled

a guest Aug 23rd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top