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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:43:57+00:00 2026-06-03T14:43:57+00:00

I am still a beginner but trying to learn so probably doing something extremely

  • 0

I am still a beginner but trying to learn so probably doing something extremely silly. My question is about a simple Android calculator I am trying to make but I think the question concerns basic Java which I thought I understood. I get the value from the button that’s pressed then pass it to a method to display the input then set a global variable for the input. The value in the method header is “1” if I press “1” but then gets lost in that method. Maybe I don’t understand how to handle the Java types as I thought I did–don’t know. I had the logic working at one time but had to change how it was displayed and that, of course, screwed up my logic somewhere. Anyway, I will post the passing statements and the receiving method for now. Thanks in advance.

  public void initButtons()
{
    //register buttons as listeners
    final Button button1 = (Button) findViewById(R.id.button1);
    final Button button2 = (Button) findViewById(R.id.button2);
    final Button button3 = (Button) findViewById(R.id.button3);
    final Button button4 = (Button) findViewById(R.id.button4);
    final Button button5 = (Button) findViewById(R.id.button5);
    final Button button6 = (Button) findViewById(R.id.button6);
    final Button button7 = (Button) findViewById(R.id.button7);
    final Button button8 = (Button) findViewById(R.id.button8);
    final Button button9 = (Button) findViewById(R.id.button9);
    final Button button10 = (Button) findViewById(R.id.button10);
    final Button addButton = (Button) findViewById(R.id.addButton);
    final Button subButton = (Button) findViewById(R.id.subButton);
    final Button multButton = (Button) findViewById(R.id.multButton);
    final Button divButton = (Button) findViewById(R.id.divButton);
    final Button calcButton = (Button) findViewById(R.id.calcButton);
    final Button clearButton = (Button) findViewById(R.id.clearButton);

    //when button is pressed, send num to calc function
    button1.setOnClickListener
    (new Button.OnClickListener()
        {
            public void onClick(View v)
            {
                inputString = button1.getText().toString();
                displayCalc(inputString);
                //displayCalc(1.0);
            }
        }
    );

    private void displayCalc(String curValue)
{
    if (hasChanged = false)
    {
        //display number if reset
        String display = curValue;
        number1 = Double.parseDouble(display);
    }
    else                                                    
    {
    //  display = display + operator + curValue;
        //number2 = Double.parseDouble(curValue);
    }
    //showDisplay(display);
}
  • 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-03T14:43:59+00:00Added an answer on June 3, 2026 at 2:43 pm

    Comparisons in Java are made with double equal signs “==”.

    It is considered better form to test for booleans simply by putting them between the parentheses like this :

    if(myBool){
        //do something
    }
    else if(!myOtherBool){
        //do something else
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for posting such a lowly beginner's question, but I just still don't know
Very beginner level question. Trying to learn JSON and having trouble with getting proper
I know this is a srs beginner question, but here goes: I am trying
Still an iphone dev starter but trying. I would like to have the user
Sorry for the beginner question, but I can't figure out cProfile (I'm really new
I am a beginner to Android but I seem to be running across a
I'm a beginner at PHP, and I'm still trying to work out proper file
I am a beginner to the Linux Kernel and I am trying to learn
I'm still a complete beginner in the field of web development and I'm trying
I am a beginner android developer and I am trying to have a button

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.