jeudi 11 août 2016

Building views dynamically and make them reusable as much as possible

Let's assume we have a fragment and somewhere along its contents we have a part that is supposed to display X views.
We don't know the X number since it is not fixed.
Each of the X views can completely different. E.g.

Separator  
TextView  
Separator  
Linear View with children  
Separator  
TextView  
Separator etc  

you get the idea.
So I was thinking
1) should this be build as some kind of custom component? How would I pass the data?
2) I originally thought this should be an inner fragment but then I thought that I don't care about the activity lifecycle about this.
3) Another approach is to just have a small function inside my fragment to add these programmatically but then how could I make this reusable?

What is the best strategy on these kind of designs?

Aucun commentaire:

Enregistrer un commentaire