質問編集履歴
1
問題の箇所を記述
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,9 +14,85 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
###
|
17
|
+
###コード
|
18
|
+
|
19
|
+
問題の箇所
|
20
|
+
|
21
|
+
```
|
22
|
+
|
23
|
+
equalBtn.setOnClickListener(new OnClickListener() {
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
@Override
|
28
|
+
|
29
|
+
public void onClick(View v) {
|
30
|
+
|
31
|
+
num2 = Integer.parseInt(tvResult.getText().toString());
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
if(op == "+"){
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
tvResult.setText("0");
|
40
|
+
|
41
|
+
num1 = num1 + num2;
|
42
|
+
|
43
|
+
tvResult.setText(String.valueOf(num1));
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
});
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
``` private void preCalc(View v) {
|
60
|
+
|
61
|
+
//vの値をopへ格納
|
62
|
+
|
63
|
+
Button opCode =(Button)v;
|
64
|
+
|
65
|
+
op = opCode.getText().toString();
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
//opが+のとき処理をする
|
70
|
+
|
71
|
+
if(op == "+"){
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
//テキストビューから値を取得しnum1へ格納する
|
76
|
+
|
77
|
+
num1 = Integer.parseInt(tvResult.getText().toString());
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
//テキストビューの値を初期値にする
|
82
|
+
|
83
|
+
tvResult.setText("0");
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
以下全ソース
|
94
|
+
|
95
|
+
|
20
96
|
|
21
97
|
```androi java
|
22
98
|
|