How can I open another layout xml file when I click on a button in main.xml file?
so if I have main.xml which has a button sying click here and I click it, it opens up second.xml file (layout).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First Create your two layout:
main.xml
second.xml
Second Add your Activity to the manifest file
Activity1.java
To switch to Activity2 you have to:
Gets a reference to the button with ID Button01 on the layout using
(Button) findViewById(R.id.Button01).Create an OnClick listener for the button.
Activity. The intent needs two parameters: a context and the name of
the Activity that we want to start (Activity2.class)
Activity2.java