'How to access children components of a view inside a LinearLayout that has been added as view inflated with viewBinding?
I want to know how to access innerElement inside a custom view that was added inside a LinearLayout.
Working inside a Fragment I create a view like this:
val view = ConstrainLayout1Binding.inflate(layoutInflater)
then add some data to ConstrainLayout1 components like view.innerElement = something
then add this view to a LinearLayaout inside a cardView
binding.MyMaterialCard.MyLinearLayout.addView(view.root)
Now in another part of the fragment I need to iterate MyLienarLayout and accesss ConstrainLayout1 elements:
When I do
binding.MyMaterialCard.MyLinearLayout.children.forEachIndexed { index, view-> as here I have a view I cannot access elements inside ConstrainLayout1
view.innerElement not posible
}
How should I iterate the LinearLayout to have access again to the innerElements?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
