• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with multiple Layouts

Coding in Java
Eclipse
Android SDK

In Eclipse in "Project name"/res/layout/ I have a main.xml which is my main view.
I have created a second xml file in there that I want a button that I have in my main.xml to change the layout to that. Can some one put up some code to help me on this?

main.xml other OVSO.xml
button is button3
 
I'm not sure exactly what you're trying to do ... I usually create a separate activity for a new view, but I think you should be able to do something like this:

Code:
             // get the button resource in the xml file and assign it to a local variable of type Button
            Button yourButton = (Button)FindViewById(Resource.Id.your_button);
            yourButton.Click += new EventHandler(yourButton_Click);

        public void yourButton_Click(object sender, EventArgs e)
        {
             SetContentView(Resource.Layout.OVSO);
        }
 
Back
Top Bottom