JozackOverFlow
JozackOverFlow

Reputation: 267

Two separate screens on one view

I used to create android app with basic layouts in android such as linear layout. I'm a student working on an android project and now my teacher want me to create an app with different graphic interface, so I got up with an idea but I don't know exactly how I can do it.

I want 2 seperate screens (let's call it Menu1 and Menu2), the Menu2 has some buttons, when I click on those button, Menu2 will become submenu1, or submenu2, submenu3. But during the transition of Menu2, Menu1 is still remain. Is there any way I can do it? I'd be really appreciate if you can give me a link to a tutorial or somethings like that.

I try to explain my idea in the picture below.

Here is the link to the picture

Upvotes: 1

Views: 95

Answers (1)

JNI_OnLoad
JNI_OnLoad

Reputation: 5442

Yes, you can use Layoutmanager to do this, check this out...

protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    LinearLayout layoutmanager = new LinearLayout(this);
    layoutmanager.setOrientation(LinearLayout.HORIZONTAL);
    setContentView(layoutmanager);
    LayoutInflater inf = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    RelativeLayout layleft = (RelativeLayout)inf.inflate(R.layout.firstxml,null);
    RelativeLayout layright = (RelativeLayout)inf.inflate(R.layout.secondxml,null);
    RelativeLayout.LayoutParams relParam = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
        layoutmanager.addView(layright, 250, 450);
        layoutmanager.addView(layleft, relParam);

You can use LinearLayout Vertical instead of Horizontal and make sure both the xml you use must have only relative layouts ..I hope It would solve your problem

Upvotes: 4

Related Questions