Reputation: 5821
Can I choose different layout for the Fragment based on the Button that has been clicked on the Activity, or should I create one Fragment class for each Button?
I know that Fragments exist to accommodate different UI but in my case I have many buttons that on click display a FrameLayout and I was thinking if it is possible to save time from copy/paste ?
Upvotes: 0
Views: 362
Reputation: 13957
I'd say that depends on how your layouts/fragments look like. If they are huge and very similar it could be better to have one layout. You could also think about using <merge />
or <include/>
in that case.
This way you can maintain equal parts in (sub-)layouts without the need of code repetition.
Have a look at Googles site here.
Upvotes: 1