I have my main activity. Inside this main activity I want to create an unknown number of layouts that each one of them include one button.
I want smart way to do it – make the layout one time and than use it a lot of time.
Trying to be smart commonly results in the opposite. Better keep it simple;
Which means, just add three buttons and then show either one of them.
This has the advance, that the events are already bound, ready to click.
And also, meanwhile it’s a whole lot more common to inflate Fragment
or to data-bind views, which would permit for hiding/showing buttons.
2
Answers
Make One Layout Resource File Using Below Code
And In Your Main Activity Layout You Can Use Only
Trying to be smart commonly results in the opposite. Better keep it simple;
Which means, just add three buttons and then show either one of them.
This has the advance, that the events are already bound, ready to click.
And also, meanwhile it’s a whole lot more common to inflate
Fragment
or to data-bind views, which would permit for hiding/showing buttons.