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

The Archive Base Latest Questions

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

I finally finished coding my Android calculator after so long. But the calculator won’t

  • 0

I finally finished coding my Android calculator after so long. But the calculator won’t even start. I’d post the logcat but I don’t know how to do so. Here is my code:

///////////////////////////////////////////////////////////////

package rechee.cool;

import android.app.Activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;




public class HelloAndroidActivity extends Activity {


    /** Called when the activity is first created. */
    public EditText display;

    double total1=0.0;
    double total2=0.0;
    char theOperator;
    public String buttonText;
    public Button ButtonAdd, ButtonEqual, ButtonMultiply, ButtonDivide, ButtonMinus;

    @Override
    public  void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        display= (EditText) findViewById(R.id.editText1);
      }

        String display1= display.getText().toString();
        double displayValue= Double.parseDouble(display1);

        public void getOperator(String btnText){
            theOperator = btnText.charAt(0);



            total1+=displayValue;
            display.setText("");
        }


            public void onClick(View v) {
                switch(v.getId()){
                    case R.id.bOne:

                        display.append("1");
                        break;
                    case R.id.bTwo:

                        display.append("2");
                        break;
                    case R.id.bThree:
                        display.append("3");
                        break;
                    case R.id.bFour:
                        display.append("4");
                        break;
                    case R.id.bFive:
                        display.append("5");
                        break;
                    case R.id.bSix:
                        display.append("6");
                        break;

                    case R.id.bSeven:
                        display.append("7");
                        break;
                    case R.id.bEight:
                        display.append("8");
                        break;
                    case R.id.bNine:
                        display.append("9");
                        break;
                    case R.id.bZero:
                        display.append("0");
                        break;
                    case R.id.bPoint:
                        display.append(".");
                        break;
                    case R.id.bClear:
                        display.setText("");
                        break;
                    case R.id.bAdd:
                        buttonText="+";
                        ButtonAdd= (Button)findViewById(R.id.bAdd);

                        ButtonAdd.setText(buttonText);


                        getOperator(buttonText);
                        break;
                    case R.id.bMinus:
                        buttonText="-";
                        ButtonMinus= (Button)findViewById(R.id.bMinus);
                        ButtonMinus.setText(buttonText);
                        getOperator(buttonText);
                        break;
                    case R.id.bMultiply:
                        buttonText="*";
                        ButtonMultiply= (Button)findViewById(R.id.bMultiply);
                        ButtonMultiply.setText(buttonText);
                        getOperator(buttonText);
                        break;
                    case R.id.bDivide:
                        buttonText="/";
                        ButtonDivide= (Button)findViewById(R.id.bDivide);
                        ButtonDivide.setText(buttonText);
                        getOperator(buttonText);
                        break;  
                    case R.id.bEqual:

                        switch (theOperator){
                        case '+':
                        total2= total1 + displayValue;
                        break;
                        case '-':
                        total2= total1 - displayValue;
                        break;
                        case '*':
                        total2= total1 * displayValue;
                        break;
                        case '/':
                        total2= total1 / displayValue;

                        break;


                        }
                        display.setText(Double.toString(total2));
                        total1=0;

                        }

                        }


}

Here’s the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="rechee.cool"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".HelloAndroidActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

And here’s link to logcat:
http://textsnip.com/529359

Please help me out.

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

    display is null so ….try this

    String display1;
    double displayValue;
    
         @Override
            public  void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                display= (EditText) findViewById(R.id.editText1);
    
            if(display.length()!=0){
              display1= display.getText().toString();
              displayValue= Double.parseDouble(display1);
              }
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with building my iPhone app..so, i finally finished it, but
I have finally finished reading Pro ASP.NET MVC 2 Framework Chapter 3: Pre-requisites but
Still learning a lot.. But basically finally finished my website, but now I'm failing
Hey, I spent A LOT of time learning about Android coding and I finally
Finally deployed my ruby on rails 3.2 app but when trying to open it
Finally figured it out thanks to One Mad Monkey, but forgot quotes on my
I finally got my permalinks working for Custom Post Types and Taxonomies using `
I've almost got it finished. but there's a little problem in adding comments. I've
When I have finally finished my jQuery plugin, is there an easy way to
I finally finished my website and low and behold, there are some inconsistencies in

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.