質問編集履歴
1
情報の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,6 +3,66 @@
|
|
3
3
|
しかし、ImageButtonは押せるのですが、クリックした回数が何も表示されません。
|
4
4
|
|
5
5
|
MainActivityには
|
6
|
+
|
7
|
+
```Java
|
8
|
+
|
9
|
+
import android.support.v7.app.AppCompatActivity;
|
10
|
+
|
11
|
+
import android.os.Bundle;
|
12
|
+
|
13
|
+
import android.view.View;
|
14
|
+
|
15
|
+
import android.widget.TextView;
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
public class MainActivity extends AppCompatActivity {
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
@Override
|
24
|
+
|
25
|
+
protected void onCreate(Bundle savedInstanceState) {
|
26
|
+
|
27
|
+
super.onCreate(savedInstanceState);
|
28
|
+
|
29
|
+
setContentView(R.layout.activity_main);
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
findViewById(R.id.imageButton1).setOnClickListener(new View.OnClickListener() {
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
int mLike = 0;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
@Override
|
42
|
+
|
43
|
+
public void onClick(View view) {
|
44
|
+
|
45
|
+
TextView textview = (TextView)findViewById(R.id.textView1);
|
46
|
+
|
47
|
+
textview.setText(Integer.toString(mLike++));
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
});
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
と記載し、
|
64
|
+
|
65
|
+
activity_main.xmlには
|
6
66
|
|
7
67
|
```Java
|
8
68
|
|
@@ -84,7 +144,7 @@
|
|
84
144
|
|
85
145
|
android:paddingTop="@dimen/activity_vertical_margin"
|
86
146
|
|
87
|
-
tools:context="
|
147
|
+
tools:context="xxxxxxxxx.button.MainActivity">
|
88
148
|
|
89
149
|
|
90
150
|
|
@@ -116,7 +176,7 @@
|
|
116
176
|
|
117
177
|
android:text="TextView" />
|
118
178
|
|
119
|
-
</RelativeLayout>
|
179
|
+
</RelativeLayout>>
|
120
180
|
|
121
181
|
|
122
182
|
|