Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8450097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:52:48+00:00 2026-06-10T10:52:48+00:00

Hey I am trying to get different buttons to open up different pages in

  • 0

Hey I am trying to get different buttons to open up different pages in a android project but only on of the buttons is opening up a new page.

I am new to programming so my terminology may not be correct but I was following a youtube tutorial and it showed how to create a button and make it open up a new page. I tried to do this for multiple buttons but I think I am making the mistake in the main activity. Sorry if I haven’t provided the write information to help me solve the problem.

package test.activity.today;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle; 
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ActivityTutorialActivity extends Activity {
/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button next = (Button) findViewById(R.id.next_button);
    next.setOnClickListener(new OnClickListener(){

        public void onClick (View v){
            Intent myIntent = new Intent(v.getContext(), NextActivity.class);
            v.getContext().startActivity(myIntent);

        }               
    });
}

public void onCreate1(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button next = (Button) findViewById(R.id.question_button);
    next.setOnClickListener(new OnClickListener(){

        public void onClick (View v){
            Intent myIntent = new Intent(v.getContext(), Question.class);
            v.getContext().startActivity(myIntent);

        }               
    });
}


public void onCreate2(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button next = (Button) findViewById(R.id.owner_cost);
    next.setOnClickListener(new OnClickListener(){

        public void onClick (View v){
            Intent myIntent = new Intent(v.getContext(), Owner.class);
            v.getContext().startActivity(myIntent);
        }
    });
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:52:49+00:00Added an answer on June 10, 2026 at 10:52 am

    you should only have one onCreate() method.. check android activity’s life cycle to understand it

    package test.activity.today;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle; 
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    
    public class ActivityTutorialActivity extends Activity {
    /** Called when the activity is first created. */
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    Button next = (Button) findViewById(R.id.next_button);
    next.setOnClickListener(new OnClickListener(){
    
        public void onClick (View v){
            Intent myIntent = new Intent(v.getContext(), NextActivity.class);
            v.getContext().startActivity(myIntent);
    
        }               
    });
    Button question = (Button) findViewById(R.id.question_button);
    question.setOnClickListener(new OnClickListener(){
    
        public void onClick (View v){
            Intent myIntent = new Intent(v.getContext(), Question.class);
            v.getContext().startActivity(myIntent);
    
        }               
    });
    Button ownerCost = (Button) findViewById(R.id.owner_cost);
    ownerCost.setOnClickListener(new OnClickListener(){
    
        public void onClick (View v){
            Intent myIntent = new Intent(v.getContext(), Owner.class);
            v.getContext().startActivity(myIntent);
        }
    });
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, i'm trying to get a project to work, but i am having trouble
Hey, im trying to get an INSERT command to work, but I keep getting
Hey all. Trying to get a little more efficient with lists in Python but
Hey, Im trying to get the signal pre_save to work on my model but
Hey I'm trying to get this working but I am not a c# programmer.
Hey I'm pretty new to XSLT's and trying to get my head around using
Hey I'm trying to get the date from the CallLog.Calls in Android. I'm doing
Hey there, I am trying to get my signout button to work. This is
Hey brilliant minds out there, I'm trying to get this Python script that I
Hey all, i have a problem with trying to get 2 forms to close

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.