Search code examples
androidkotlingrouping

Android - Kotlin - How to iterate Group children elements


I have several Spinners and TextViews which are grouped together in a <android.support.constraint.Group> tag.

How does one iterate the elements of the group?

I have tried

val ids = findViewById<Group>(R.id.group_lala).referencedIds
for (id in ids) {
        val frm = findViewById<*>(id)
    }

But I cannot have *


Solution

  • You should be able to do

    val ids = findViewById<Group>(R.id.group_lala).referencedIds
    for (id in ids) {
        val view = findViewById<View>(id)
    }