質問編集履歴
1
情報の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,6 +32,36 @@
|
|
32
32
|
と記載し、
|
33
33
|
activity_main.xmlには
|
34
34
|
```Java
|
35
|
+
import android.support.v7.app.AppCompatActivity;
|
36
|
+
import android.os.Bundle;
|
37
|
+
import android.view.View;
|
38
|
+
import android.widget.TextView;
|
39
|
+
|
40
|
+
public class MainActivity extends AppCompatActivity {
|
41
|
+
|
42
|
+
@Override
|
43
|
+
protected void onCreate(Bundle savedInstanceState) {
|
44
|
+
super.onCreate(savedInstanceState);
|
45
|
+
setContentView(R.layout.activity_main);
|
46
|
+
|
47
|
+
findViewById(R.id.imageButton1).setOnClickListener(new View.OnClickListener() {
|
48
|
+
|
49
|
+
int mLike = 0;
|
50
|
+
|
51
|
+
@Override
|
52
|
+
public void onClick(View view) {
|
53
|
+
TextView textview = (TextView)findViewById(R.id.textView1);
|
54
|
+
textview.setText(Integer.toString(mLike++));
|
55
|
+
|
56
|
+
}
|
57
|
+
});
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
```
|
62
|
+
と記載し、
|
63
|
+
activity_main.xmlには
|
64
|
+
```Java
|
35
65
|
<?xml version="1.0" encoding="utf-8"?>
|
36
66
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
37
67
|
xmlns:tools="http://schemas.android.com/tools"
|
@@ -41,7 +71,7 @@
|
|
41
71
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
42
72
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
43
73
|
android:paddingTop="@dimen/activity_vertical_margin"
|
44
|
-
tools:context="
|
74
|
+
tools:context="xxxxxxxxx.button.MainActivity">
|
45
75
|
|
46
76
|
<ImageButton
|
47
77
|
android:id="@+id/imageButton1"
|
@@ -57,7 +87,7 @@
|
|
57
87
|
android:layout_toRightOf="@+id/imageButton1"
|
58
88
|
android:layout_marginLeft="5dip"
|
59
89
|
android:text="TextView" />
|
60
|
-
</RelativeLayout>
|
90
|
+
</RelativeLayout>>
|
61
91
|
|
62
92
|
```
|
63
93
|
|