I have a "complex" xml with some layouts inside. For example
LinearLayout
LinearLayout
TextView (title)
ImageView
LinearLayout
TextView
TextView
LinearLayout
TextView
ImageView (icon)
In my application I need to reuse that block but changing some attributes (for example the title and icon) leaving the rest untouched.
Is posible to declare that parameters in the XML and change those attributes in the include po开发者_Go百科int? Or I must make it programmatically at the onCreate/onResume/inflate of the view?
Thanks
Bonjour Caroline,
you need to inflate a static xml and change programmaticaly the dynamic parts. Use ids to retrieve the widgets you want to modify and change their properties after inflating.
Also, you could consider using other layouts, nested linear layouts tends to be slower and less effective than a big relative layout for all components.
Regards, Stéphane
精彩评论