-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathSubHandler.java
More file actions
35 lines (23 loc) · 915 Bytes
/
SubHandler.java
File metadata and controls
35 lines (23 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.calculator;
import java.util.ArrayList;
import android.widget.TextView;
public class SubHandler implements Handler{
private double value1;
private double value2;
private double result;
private String resultString;
@Override
public void handleIt(Object ... parameters) {
//pull the CalculatorActivity from the Calculator class and assigns to activity
CalculatorActivity activity = (CalculatorActivity) parameters[0];
//declare Textviews from textViews pass from Calculator
TextView inputTxt = (TextView) parameters[1];
TextView solutionTxt = (TextView) parameters[2];
value1 = Double.parseDouble(inputTxt.getText().toString());
value2 = Double.parseDouble(solutionTxt.getText().toString());
result = value2 - value1;
resultString = Double.toString(result);
solutionTxt.setText(resultString);
inputTxt.setText("");
}
}