I am creating a screen/xml which has:
- TextView (Header)
- LinearLayout (placeholder to contain numerous RelativeLayouts)
I need to add many RelativeLayout
(containing two TextView
s) to the LinearLayout
(mentioned above) in loop. This basically would be list of RelativeLayouts
. I have two ways doing this:
- Create an xml file which has the
RelativeLayout
(and twoTextViews
under it). Inflate this in the code again and again( in loop).And then add this toLinearLayout
mentioned above. - Create the instance of
RelativeLayout
andTextView
using the keyword "new". And add the instances to the above mentionedLinearLayout
.
Which is the least expensive way.