質問編集履歴
1
あらたに質問書き直すj
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,129 +1,7 @@
|
|
1
1
|
アンドロイドのTween animation を使用してます。画面の上にtransとrotateのボタンが2つあり、transボタンを押すと画像a1が現れて、それが動き、rotateボタンを押すと画像b1が現れ、それが動くという仕組みです。
|
2
2
|
|
3
|
-
問題は一方が動作している途中に、他方のボタンを押すと同時に2つの画像が画面上で動作することです。つねに一方だけ動作して、その動作が終わった後に、他方が動作できるようにしたいのですが、そのようなcodeがわかりません。
|
3
|
+
問題は一方が動作している途中に、他方のボタンを押すと同時に2つの画像が画面上で動作することです。つねに一方だけ動作して、その動作が終わった後に、他方が動作できるようにしたいのですが、そのようなcodeがわかりません。教えていただければ助かります。
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
java
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
public class MainActivity extends AppCompatActivity {
|
12
|
-
|
13
|
-
Button btn1;
|
14
|
-
|
15
|
-
Button btn2;
|
16
|
-
|
17
|
-
@Override
|
18
|
-
|
19
|
-
public void onCreate(Bundle savedInstanceState) {
|
20
|
-
|
21
|
-
super.onCreate(savedInstanceState);
|
22
|
-
|
23
|
-
setContentView(R.layout.activity_main);
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
final ImageView img = (ImageView) findViewById(R.id.img);
|
28
|
-
|
29
|
-
final ImageView img2 = (ImageView) findViewById(R.id.img2);
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
btn1 = (Button) findViewById(R.id.btn1);
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
final Animation anim = AnimationUtils.loadAnimation(this, R.anim.trans);
|
38
|
-
|
39
|
-
btn1.setOnClickListener(new View.OnClickListener() {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@Override
|
44
|
-
|
45
|
-
public void onClick(View v) {
|
46
|
-
|
47
|
-
img.setVisibility(View.VISIBLE);
|
48
|
-
|
49
|
-
img2.setVisibility(View.INVISIBLE);
|
50
|
-
|
51
|
-
img.startAnimation(anim);
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
});
|
58
|
-
|
59
|
-
btn2 = (Button) findViewById(R.id.btn2);
|
60
|
-
|
61
|
-
btn2.setOnClickListener(new View.OnClickListener() {
|
62
|
-
|
63
|
-
final Animation anim = AnimationUtils.loadAnimation(MainActivity.this, R.anim.rotate);
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@Override
|
68
|
-
|
69
|
-
public void onClick(View v) {
|
70
|
-
|
71
|
-
img2.setVisibility(View.VISIBLE);
|
72
|
-
|
73
|
-
img.setVisibility(View.INVISIBLE);
|
74
|
-
|
75
|
-
img2.startAnimation(anim);
|
76
|
-
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
});
|
82
|
-
|
83
|
-
}}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
xml
|
88
|
-
|
89
|
-
|
7
|
+
あらたに質問を書き直します
|
90
|
-
|
91
|
-
android:layout_height="wrap_content"
|
92
|
-
|
93
|
-
android:layout_width="wrap_content"
|
94
|
-
|
95
|
-
android:src="@drawable/a1"
|
96
|
-
|
97
|
-
android:layout_centerHorizontal="true"
|
98
|
-
|
99
|
-
android:layout_marginTop="5dp"
|
100
|
-
|
101
|
-
android:layout_marginLeft="15dp"
|
102
|
-
|
103
|
-
android:visibility="invisible"
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
android:id="@+id/img"/>
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
<ImageView
|
114
|
-
|
115
|
-
android:layout_height="wrap_content"
|
116
|
-
|
117
|
-
android:layout_width="wrap_content"
|
118
|
-
|
119
|
-
android:src="@drawable/b1"
|
120
|
-
|
121
|
-
android:layout_centerHorizontal="true"
|
122
|
-
|
123
|
-
android:layout_marginTop="5dp"
|
124
|
-
|
125
|
-
android:layout_marginLeft="150dp"
|
126
|
-
|
127
|
-
android:id="@+id/img2"
|
128
|
-
|
129
|
-
android:visibility="invisible"
|