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

  • SEARCH
  • Home
  • 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 4618796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:20:23+00:00 2026-05-22T02:20:23+00:00

I have three buttons on my main page. Something weird happens when I try

  • 0

I have three buttons on my main page. Something weird happens when I try to click on them. For example, when I click on the NewGame button, it first displays what the scores button should display, and then if I click the back button it will proceed to display the activity that it was meant to. With the About button, I have to click back twice (it displays the newGame activity and the scores activity. Is there a reason why this is happening?

public class Sakurame extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);

    //set up click listeners for buttons
    View HighScoreButton = findViewById(R.id.highscore_button);
    HighScoreButton.setOnClickListener(this);
    View newButton = findViewById(R.id.new_button);
    newButton.setOnClickListener(this);
    View aboutButton = findViewById(R.id.about_button);
    aboutButton.setOnClickListener(this);

}

@Override
public boolean onCreateOptionsMenu(Menu menu){
    super.onCreateOptionsMenu(menu);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item){
    switch (item.getItemId()){
    case R.id.settings:
        startActivity(new Intent(this, Prefs.class));
        return true;
        // More items go here (if any)
    }
    return false;
}

public void onClick(View v){
    switch(v.getId()){
    case R.id.about_button:
        Intent i = new Intent(this, About.class);
        startActivity(i);
    case R.id.new_button:
        Intent i2 = new Intent(this, HighScore.class);
        startActivity(i2);
    case R.id.highscore_button:
        Intent i3 = new Intent(this, DisplayScores.class);
        startActivity(i3);
        //break;

        // more buttons go here (if any)
    }
}
  • 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-05-22T02:20:23+00:00Added an answer on May 22, 2026 at 2:20 am

    Try adding break; after each startActivity within the onClick method.

    Edit to clarify. This ensures that once the case has been met, the switch statement is broken from instead of moving on to the next case statement.

        case R.id.about_button:
            Intent i = new Intent(this, About.class);
            startActivity(i);
            break;
        case R.id.new_button:
            Intent i2 = new Intent(this, HighScore.class);
            startActivity(i2);
            break;
        case R.id.highscore_button:
            Intent i3 = new Intent(this, DisplayScores.class);
            startActivity(i3);
            break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three radio buttons with same name and different values.When I click the
In my page I have three radio buttons and I want to checked the
I have a group of three radio buttons. Depending on which radio button is
So I have my main page with buttons on top of it. Below there's
I have three pages main page popup page started from main page using onclick
I have a flash file that has three main buttons on top. When a
I have three buttons and need to save some data. I have a idea,
I have three buttons in a three column structure in a custom cell in
I have div which has three buttons as, <div id=buttons> <input id=preview class=ButtonStyle type=submit
I have one label field and three buttons with the name of red, yellow,

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.