Created
June 28, 2019 13:48
-
-
Save Temidtech/4a928e8fe44ca9fde2f81ab768ed5840 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extend ViewGroup class with inflate function | |
fun ViewGroup.inflate(layoutRes: Int): View { | |
return LayoutInflater.from(context).inflate(layoutRes, this, false) | |
} | |
================================== | |
// Call inflate directly on the ViewGroup instance | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
val v = parent.inflate(R.layout.view_item) | |
return ViewHolder(v) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment