Issue
I have this function which deletes all elements of a type in a layout.
fun DeleteAllOfTypeInLayout(t:TYPE){
for(child in layout.children){
if(child is t)
layout.removeView(child)
}
}
How can have this TYPE parameter?
Solution
Check Kotlin's Reified type parameters
inline fun <reified T> DeleteAllOfTypeInLayout() {
for (child in layout.children) {
if (child is T)
layout.removeView(child)
}
}
// DeleteAllOfTypeInLayout<TextView>()
Answered By - Akaki Kapanadze
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.