I am new to programming. I made a simple Android application that asked the user to put 2 numbers, perform calculations, display the answer by clicking the calculation button. Now I'm trying to configure the reset button to clear all fields. A tested solution for, but still can not figure out how to do it. This is my code:
public void calculate(View view) { EditText number1 = (EditText)findViewById(R.id.num1ID); EditText number2 = (EditText)findViewById(R.id.num2ID); Double num1Value = Double.parseDouble(number1.getText().toString()); Double num2Value = Double.parseDouble(number2.getText().toString()); Double resultValue = num1Value - num2Value; TextView resultDisplay = (TextView)findViewById(R.id.resultID); resultDisplay.setText(Double.toString(resultValue)); }
Thanks.
source share