I want something like setContentView but for a FrameLayout inside of my current layout means that I have some bunch of controls in my main_activity layout and one of them is pageHolder which is a FrameLayout. I added an android layout in res/layout which is also FrameLayout called page1 and another one called page 2. I want to change the content of pageHolder to the content of page1 or page2 when application is running.
I do the following code but it gives me error:
FrameLayout pageHolder = (FrameLayout)findViewById(R.id.pageHolder);
FrameLayout page1 = (FrameLayout)findViewById(R.layout.page1);
pageHolder.removeAllViews();
pageHolder.addView(page1);
and it says page1 is null and I have checked it myself and it was null. Can you help me please?
It seems to me that you should use
LayoutInflaterto inflate that page1 layout. It should look something like this: