kirillrakhman
02/29/2016, 12:46 PMinclude
set the parent container when inflating the xml layout? It's implemented as
inline fun <T: View> ViewManager.include(layoutId: Int, init: T.() -> Unit): T {
@Suppress("UNCHECKED_CAST")
return ankoView({ ctx -> ctx.layoutInflater.inflate(layoutId, null) as T }) { init() }
}
why not have an overload where the receiver is of type ViewGroup
and it is passed as the second argument to inflate
like so:
inline fun <T : View> ViewGroup.include(layoutId: Int, init: T.() -> Unit): T {
@Suppress("UNCHECKED_CAST")
return ankoView({ ctx -> ctx.layoutInflater.inflate(layoutId, this@include, false) as T }) { init() }
}