Search code examples
javaandroidandroid-edittextchildren

Android Development: How To Get All EditText Children of a ViewGroup?


Basically, I have a LinearLayout that holds a random amount of horizontal LinearLayouts, and in each of the horizontal LinearLayouts there's a TextView and an EditText. I want to be able to get the value of each EditText children of the master LinearLayout.

Sorry if it's confusing, I'm no good at explaining things!

Could I just set the same ID for each of the EditTexts then use findViewById, or would that only return the first instance of an EditText?

Thanks, Alex.


Solution

  • You would need to call findViewById on each of the LinearLayouts. If you do this, you can set the same ID for each EditText.