0

Today I've been attempting to make an application with multiple page , but i have looked everywhere and cannot find a tutorial in english to follow , but heres what im trying to do ,

When i click a button i want it to take me to a specific XML layout (Example , "Button1" takes the user to "Page1.xml"

thanks for your time!

CrackerzUnk

3 Answers 3

1

User onClick listener for your button and then start your activity as

        button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // here you can start new activity
                     Intent intentnew=new Intent(currenclass.this,newActivity.class);
                     startActivity(intentnew);
                     finish();

        }
    });
Sign up to request clarification or add additional context in comments.

Comments

0

Use the android:onClick attribute for the Buttons and specify a method in you Activity that according to the button pressed starts the new Activity.

Comments

0

Define an Activity class for Page1.xml , say for example Page1Activity.class, now based on the button click (from another activity) start this activity:

button1.setOnClickListener(new OnClickListener()
{
    @override
    public void onClick(View v)
    {
        // using Intent you can start another activity
         Intent intent = new Intent(ManActivity.this,Page1Activity.class);
         startActivity(intent);
    }
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.