Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@JvmStatic
fun getAllChildren(v: View, recursive: Boolean, ignoredElements: List<View>): ArrayList<View> {
if (v !is ViewGroup || v.childCount == 0) {
val r = ArrayList<View>()
r.add(v)
return r
} else {
val list = ArrayList<View>()
list.add(v)
val children = v.childCount
for (i in 0 until children) {
val child = v.getChildAt(i)
if (!ignoredElements.contains(child)) {
if (recursive) {
list.addAll(getAllChildren(child, recursive, ignoredElements))
} else {
list.add(child)
}
}
}
return list
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.