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 7534647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:04:51+00:00 2026-05-30T06:04:51+00:00

Overview: I have two pages in my program; the main page and the other

  • 0

Overview:
I have two pages in my program; the main page and the other page.

On the main page I have two buttons; one button switches to the other page and the Add button adds some values together.

On the other page I have a single button that brings me back to the main page.

Currently I’m able to switch between the two pages without issue.

My Issue:
When I first open the program I can click the Add button and it will add the values together. I can continue to change between the two pages without issue.
However, after I have switched pages, when I click the Add button, my program crashes.

Here is my java file.

    package com.test;
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.*;

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

    Button enterScoreButton = (Button) findViewById(R.id.button1);
    enterScoreButton.setOnClickListener(enterScoreButtonListener);
}

public OnClickListener enterScoreButtonListener = new OnClickListener() 
{
    @Override
    public void onClick(View v1) 
    {
    }

    public int addEntireHole(int addedHoles) {
        return (addedHoles);
    }
};

//This section goes from the main page to the other page
public OnClickListener Startpage = new OnClickListener(){
    public void onClick(View v2){
    }
};

public void onCreate(View view){
    Button buttonSwitchMain = (Button)findViewById(R.id.btnSwitch);
    buttonSwitchMain.setOnClickListener(Startpage);
    setContentView(R.layout.other);
 }

//This section goes from the other page to the main page

public OnClickListener otherpage = new OnClickListener(){
    public void onClick(View v3){
    }
};


public void onCreate3(View view2){
    Button buttontoMain = (Button)findViewById(R.id.btnBack);
    buttontoMain.setOnClickListener(otherpage);
    setContentView(R.layout.main);
 }

}

  • 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-30T06:04:53+00:00Added an answer on May 30, 2026 at 6:04 am

    In your method onCreate3, after calling setContentView you should call

    enterScoreButton.setOnClickListener(enterScoreButtonListener);
    

    once again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a overview page containing a list with some links from which multiple
I have a php page that creates page data from two .txt files (one
Overview: I have two text boxes at the top of this form for inputting
Overview I have a Microsoft Word Add-In, written in VBA (Visual Basic for Applications),
Basically, I have two classes : - MyActivity.java - OtherClass.java Overview of MyActivity.java :
I have two spreadsheets in Excel. Sheet1 is called Overview , and Sheet2 is
I have two tableview controllers showing CoreData objects. One is a detail view (with
Overview: I have an array of 20 byte strings that needs to be stored
Overview I have an iOS project which contains 2 navigation controllers as shown in
In Eclipse we are using Mylyn to have an overview of our Trac Tickets.

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.