Execute button's command after the animation
In my application i have added a frame-by-frame animation to my button's selector. So, when I press the button the application 开发者_如何学Cis started and another activity is launched. The problem is that if I press the button very quickly the application reaches only to the second frame. I would like to launch the next activity after the animation is ended. Is that possible?
The button should launch a new Thread instead new Activity directly, and then this new Thread will launch the activity after a few secconds using "Thread.sleep(xxxx);"
btn.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
new Thread()
{
public void run()
{
Thread.sleep(1000);
//LAUNCH NEW ACTIVITY HERE
}
}.start();
}
}
You should set an AnimationListener to your animation and start another activity on animation end.
You may use handler.postDelayed(Runnable);
with your delay;
精彩评论