I have two XML layouts declared in the res/layout folder one contains the generic template and the other contains the views specific to a particular screen. I want to add the second xml layout to the first one i.e. the generic one. As both of these layouts are declared as XML, I am not able to add one to other. How do I solve this problem?
+1
A:
Have you tried using a LayoutInflater and inflating your specific view and adding it to a ViewGroup or FrameLayout?
Brian
2010-09-09 04:40:07
It worked. Thanks Brian
Robin
2010-09-09 05:13:00
You're welcome. Feel free to mark this as the accepted answer.
Brian
2010-09-09 06:15:36
A:
Hi,
I have one linear-layout which contain some fields like edit-text and some buttons.. If i click one of button i want to show new page in the same activity for that i use LayoutInflater but shows only blank page.. can you please explain how you did that
Thanks
sachin
2010-09-29 07:19:05
@sachin please post this as a separate question not as an answer to this question.
Janusz
2010-09-29 07:47:00
Every activity returns a view that is rendered on mobile screen, Since on click of button you want to change the screen i.e. view of that activity itself, get the view you want to modify by tag/íd and do the changes. There is no need to use LayoutInflater
Robin
2010-10-05 09:22:13
Thanks for your help And sorry to post a question here. i solved it by using it as custom view.
sachin
2010-10-11 10:07:56
A:
I may not be understanding it correctly. But it might be a lot easier to use the <include layout="@layout/yourlayouthere" />
method to simply embed using just XML notation. I use this method to build a bunch of little parts and then pull them together in my main layout using the inlcude statement.
Michael
2010-10-09 05:00:56