android按钮动画。如何先获得动画,然后再单击活动 [英] android button animation. How to get animation first, on click before activity

查看:66
本文介绍了android按钮动画。如何先获得动画,然后再单击活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Android制作了一个可以在点击时旋转的按钮,但是当我设置按钮和新活动时,单击它只是将我设置为新活动。

I made a button for Android that rotates on click, but when I set a button and new activity, when I click it's just set me to new activity.

我只需要这样:当我单击该按钮时,首先要制作动画,例如旋转,然后执行新的活动。这是我的代码:

I need just this: when I click on that button, first to do animation e.g. rotate, then to execute a new activity. Here is my code:

ImageButton pandaButton2 = (ImageButton) findViewById(R.id.pandaButton2);

   pandaButton2.setOnClickListener(new OnClickListener(){
       public void onClick(View v){
           v.startAnimation(pandarotate);
            startActivity(new Intent("com.example.threepandas.MENU"));
}
});


推荐答案

这是我用于解决此问题的解决方案( (来自Github上的Google I / O应用源代码)

Here is the solution I use for this problem (got it from the Google I/O App Source Code on Github)

private static final int DELAY = 250;
private Handler mHandler;

@Override
        public void onClick(final View view) {
            switch (view.getId()) {
                case R.id.button:
                    mHandler.postDelayed(new Runnable() {
                        @Override
                        public void run() {

                        }
                    }, DELAY);
                    break;
            }
        }

这篇关于android按钮动画。如何先获得动画,然后再单击活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆