I am making a basic calculator for Android by eclipse and Java. The task is there are two values, like input and result. So when the first number is pressed, it saves it, then a plus or minus sign is pressed ad then the second value which is result.
My idea was to create a method for every button something like this:
public void number1(View view){
value1 = value2;
value2 = 1;
displayValue();
}
But did not work and also I am repeating a few lines many times which isnt nice. So what about using switch, or any idea to have one single method and put it on all android:onClick""
for buttons.
So if you have any idea just explain it or write an example. Thanks in advance.