Hi everyone: I’m trying to write a generic functio...
# getting-started
s
Hi everyone: I’m trying to write a generic function wrapper, but can’t seem to get it quite right. Basically I can’t seem to pass
LinearLayout
as an argument here, what’s going on?
Copy code
fun <T : View> getView (viewType : T, id: Int) : T {
            return view!!.findViewById<T>(id)
        }

        val l = getView(LinearLayout, R.id.settingsLanguageRow)
r
Copy code
inline fun <reified T: View> getView(id: Int): T {
    return view!!.findViewById<T>(id)
}
val l = getView<LinearLayout>(R.id.settingsLanguageRow)
s
works thanks 😃
👍 1