How do I add android views in run time with dynamic ID's

Viewed 669

I am making an app where at a certain fragment, I need a variable number of EditTexts in the fragment. I have an add button below the layout which when pressed should add the required Edit Text with ID's so that I can collect data from it.

For eg, if the layout starts out with Initial Layout

When I press the + button, it should add like Second Layout

So as I keep pressing the + button, I should automatically get one more layout with all the edit texts. And I need a way to keep track of the ids of all the edit texts so that I can get all the data later.

How do I go about doing this???

2 Answers
Related