I'm having two layout.xml files. I need to load either one of the XML in a activity. Say initially i will be loading an activity using SetContentView and if a button click is done then i have to load another layout.xml file.
How can i do this?
This开发者_StackOverflow社区 change will be frequently done in the activity.
Say you have layout1.xml and layout2.xml
Change between them using
setContentView(layout1);
setContentView(layout2);
Careful
If you have buttons,textviews... that you reference using
findViewById(), you must re-reference them again after callingsetContentView()
call
setContentView(layout1);
and in your onClick() method, call
setContentView(layout2);
加载中,请稍侯......
精彩评论