I implemented a function that is used in anko's apply recursively:
fun applyTemplateViewStyles(view: View) { when(view) { is EditText, TextView -> { .... } } }
And I receive an error saying that "Function invocation 'TextView(...)' expected"
Since I can write an when with a clause like is 0, 1, why I can't do the same with an Android View?
You're missing the other is:
is
fun applyTemplateViewStyles(view: View) { when(view) { is EditText, is TextView -> { println("view is either EditText or TextView") } else -> { println("view is something else") } } }
2.1m questions
2.1m answers
60 comments
56.9k users