Variable is not used in Android Calculator
<p>Using eclipse, first of all. I'm building an Android calculator. I have all my code, except there's a problem. One of my variables is not being used. My total1 variable is basically the counter for the program. When I add two numbers up and press equals, it always prints "0.0" and that's the value of total1. That means for some reason, it never changed throughout the whole program. I even tested this by using a print statement. I changed the value of total1 and it would print that value I assigned it to. What could be the problem?</p>

<pre><code>public class HelloAndroidActivity extends Activity {
    public EditText display;
    String display1;
    double displayValue;

    // Program is printing out total1, as if it weren't maninpulated in the code
    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);

        // Could it have something to do with this if statement?
        if (display.length() != 0) {
            display1 = display.getText().toString();
            displayValue = Double.parseDouble(display1);
        }
    }

    //Get the operator of the multiply, divide, subtract, add buttons when they are clicked and then do the following
    public void getOperator(String btnText) {
        theOperator = btnText.charAt(0);

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

    // Display a string in the box when a number button is clicked
    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:
            total2 = 0.0;
            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;

        // Here's the equals button. When I click it it prints out "0.0", the value of total1, instead of adding the total below
        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.0;
            break; 
        }                       
    }
}
</code></pre>
