I have a relative layout defined in a xml file(say realtive.xml). In another layout I have a relativelayout tag inside a linearlayout(say linear.xml). This realtive layout is empty and has an id say “rl”. On clicking a button in linear.xml, I want the contents of relative.xml to be set in the relative layout with id “rl”.
How should this be done?
I have a relative layout defined in a xml file(say realtive.xml). In another layout
Share
In the
onClick()method for thatButtoninflate the new layout and add it to that emptyRelativeLayout:Also if you don’t want to add the parent
RelativeLayoutfromrealtive.xmlto the emptyRelativeLayoutthen use themergetag:realtive.xml
Here you can read more about the
mergetag: http://developer.android.com/resources/articles/layout-tricks-merge.html