Skip to content

Instantly share code, notes, and snippets.

Created May 12, 2017
What would you like to do?
Magic Data Binding inflate
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding = parent.inflateBinding<ListItemCommentBinding>()
return ViewHolder(binding)
inline fun <reified T : ViewDataBinding> View.inflateBinding(): T {
.getDeclaredMethod("inflate",,, Boolean::class.javaPrimitiveType)
.invoke(null, LayoutInflater.from(context), this, false) as T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment