Created
April 23, 2018 13:51
-
-
Save Temidtech/e7b6b234d7e90bb8aa8a0f412cd25756 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