我在屏幕上有20个按钮,如果用户正确按下正确的按钮,将通过按钮动画显示分数。按错了按钮并显示否定消息也一样。
<alpha
android:duration="1000"
android:fromAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="0.0" />
<translate
android:duration="1000"
android:fromYDelta="-5%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toYDelta="-15%p" />
public void show_pop_message(int pop_message, int x, int y)
{
final RelativeLayout rl = (RelativeLayout) findViewById(R.id.overall_frame);
final TextView tv;
RelativeLayout.LayoutParams params;
tv = new TextView(this);
tv.setText(""+pop_message);
tv.setBackgroundColor(0x7C5B77);
tv.setTypeface(tf);
params = new RelativeLayout.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
if(pop_message > 0)
{
tv.setTextColor(getResources().getColor(R.color.green));
}
else
{
tv.setTextColor(getResources().getColor(R.color.bright_red));
}
tv.setTextSize(Constant.SIZE.FONTSIZE_BIG);
params.leftMargin = x;
params.topMargin = y;
rl.addView(tv, params);
// set animations
fade_out_move_up = AnimationUtils.loadAnimation(Game.this, R.anim.fade_out_move_up);
fade_out_move_up.setAnimationListener((new AnimationListener()
{
@Override
public void onAnimationEnd(Animation animation) {
rl.removeView(tv);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
}
}));
tv.startAnimation(fade_out_move_up);
}
05-25 11:48:27.113: E/ActivityThread(22376): Performing stop of activity that is not resumed: {com.abc. abc /com. abc. abc.Game}
05-25 11:48:27.113: E/ActivityThread(22376): java.lang.RuntimeException: Performing stop of activity that is not resumed: {com. abc. abc /com. abc. abc.Game}
05-25 11:48:27.113: E/ActivityThread(22376): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3345)
05-25 11:48:27.113: E/ActivityThread(22376): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3432)
05-25 11:48:27.113: E/ActivityThread(22376): at android.app.ActivityThread.access$1200(ActivityThread.java:164)
05-25 11:48:27.113: E/ActivityThread(22376): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1295)
05-25 11:48:27.113: E/ActivityThread(22376): at android.os.Handler.dispatchMessage(Handler.java:102)
05-25 11:48:27.113: E/ActivityThread(22376): at android.os.Looper.loop(Looper.java:157)
05-25 11:48:27.113: E/ActivityThread(22376): at android.app.ActivityThread.main(ActivityThread.java:5377)
05-25 11:48:27.113: E/ActivityThread(22376): at java.lang.reflect.Method.invokeNative(Native Method)
05-25 11:48:27.113: E/ActivityThread(22376): at java.lang.reflect.Method.invoke(Method.java:515)
05-25 11:48:27.113: E/ActivityThread(22376): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
05-25 11:48:27.113: E/ActivityThread(22376): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
05-25 11:48:27.113: E/ActivityThread(22376): at dalvik.system.NativeStart.main(Native Method)
05-25 11:48:27.183: D/AbsListView(22376): unregisterIRListener() is called
05-25 11:48:27.203: D/AbsListView(22376): unregisterIRListener() is called
05-25 11:48:28.123: I/System.out(22376): pool-1-thread-1 calls detatch()
05-25 11:48:28.173: I/System.out(22376): pool-1-thread-2 calls detatch()
05-25 11:48:28.473: D/ProgressBar(22376): updateDrawableBounds: left = 0
05-25 11:48:28.473: D/ProgressBar(22376): updateDrawableBounds: top = 0
05-25 11:48:28.473: D/ProgressBar(22376): updateDrawableBounds: right = 1536
05-25 11:48:28.473: D/ProgressBar(22376): updateDrawableBounds: bottom = 61
05-25 11:48:28.473: D/ProgressBar(22376): updateDrawableBounds: mProgressDrawable.setBounds()
05-25 11:48:28.543: D/AbsListView(22376): unregisterIRListener() is called
05-25 11:48:29.063: D/AbsListView(22376): onDetachedFromWindow
05-25 11:48:29.713: E/ViewRootImpl(22376): sendUserActionEvent() mView == null
05-25 11:48:30.413: W/System.err(22376): [DEBUG] GbaRequest - GbaRequest: Constructor Called 222 userAgent null
05-25 11:48:30.413: W/System.err(22376): [DEBUG] NafRequest - NafRequest: NafRequest constructor===useragent null
05-25 11:48:30.823: I/System.out(22376): Thread-8463 calls detatch()
05-25 11:48:32.373: I/System.out(22376): Thread-8463 calls detatch()
05-25 11:48:35.383: W/System.err(22376): [DEBUG] GbaRequest - GbaRequest: Constructor Called 222 userAgent null
05-25 11:48:35.383: W/System.err(22376): [DEBUG] NafRequest - NafRequest: NafRequest constructor===useragent null
05-25 11:48:35.723: I/System.out(22376): Thread-8465 calls detatch()
05-25 11:48:36.573: D/AndroidRuntime(22376): Shutting down VM
05-25 11:48:36.573: W/dalvikvm(22376): threadid=1: thread exiting with uncaught exception (group=0x41728da0)
每次按下按钮都可以正确显示popup_message分数。但是,在按下第一个按钮后,如果用户按下第二个按钮,则button1的弹出消息将再次与button2一起动画。其他按钮上的其余按钮按下相同:所有按钮&#39;动画同时表演。
我不希望动画后再次出现该消息。
上述问题是什么?如何修改?谢谢!
答案 0 :(得分:1)
动画正在运行,有效地将alpha设置为,但按钮仍在r1
内。
您可能希望将动画侦听器animetionEnd
放在:
rl.removeView(tv);