Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android动画有问题吗?_Android_Android Animation_Android Button - Fatal编程技术网

Android动画有问题吗?

Android动画有问题吗?,android,android-animation,android-button,Android,Android Animation,Android Button,在我的应用程序中,我有6个按钮。在onCreate中,我有一个startAnimation,它将为按钮的外观执行动画。调用此方法后,我为每个按钮设置了setOnclickListeners onCreate中的代码如下所示: startAnimations(); b1.setOnClickListener(this); b2.setOnClickListener(this); b3.setOnClickListener(this); b4.setOnCl

在我的应用程序中,我有6个按钮。在onCreate中,我有一个startAnimation,它将为按钮的外观执行动画。调用此方法后,我为每个按钮设置了setOnclickListeners

onCreate中的代码如下所示:

    startAnimations();

    b1.setOnClickListener(this);
    b2.setOnClickListener(this);
    b3.setOnClickListener(this);
    b4.setOnClickListener(this);
    b5.setOnClickListener(this);
    b6.setOnClickListener(this);
问题是:当我测试我的应用程序时,当动画开始时,我可以单击任何按钮,即使按钮尚未显示。我的意思是,我可以点击按钮的位置,与该按钮相关的操作将开始

我想强制按钮在整个动画结束之前不响应单击


我可以这样做吗?

button.setClickablefalse或button.setOnClickListnernull可能


也许设置这些,然后注册AnimationListener。看见调用onAnimationEnd后,button.setClickabletrue和/或button.setOnClickListenerthis。

button.setClickablefalse或button.SetOnClickListenerNull是否可能


也许设置这些,然后注册AnimationListener。看见调用onAnimationEnd后,button.setClickabletrue和/或button.setOnClickListenerthis。

您可以在调用前将动画按钮设置为enabled false

b1.setEnabled(false);
然后调用startAnimations;然后完成b1.setEnabledtrue的动画


像这样…

您可以在调用前动画按钮设置为enabled false时完成

b1.setEnabled(false);
然后调用startAnimations;然后完成b1.setEnabledtrue的动画


就像那样…

为什么不在创建或删除时禁用按钮,然后在动画结束时启用它呢

 findViewById(R.id.button1).setEnable(false);
 findViewById(R.id.button1).setEnable(false);
 ....   
 final RelativeLayout l = (RelativeLayout) findViewById(R.id.group_band);
 Animation a = new TranslateAnimation(0, 0, -100, 0);
 a.setDuration(200);
 a.setAnimationListener(new AnimationListener() {

                public void onAnimationEnd(Animation animation) {
                    findViewById(R.id.button1).setEnable(true);
                    findViewById(R.id.button2).setEnable(true);
                                             ....
                }

                public void onAnimationRepeat(Animation animation) {

                }

                public void onAnimationStart(Animation animation) {

                }

            });

 l.startAnimation(l);

你觉得怎么样?

为什么不在创建或删除时禁用按钮,然后在动画结束时启用它呢

 findViewById(R.id.button1).setEnable(false);
 findViewById(R.id.button1).setEnable(false);
 ....   
 final RelativeLayout l = (RelativeLayout) findViewById(R.id.group_band);
 Animation a = new TranslateAnimation(0, 0, -100, 0);
 a.setDuration(200);
 a.setAnimationListener(new AnimationListener() {

                public void onAnimationEnd(Animation animation) {
                    findViewById(R.id.button1).setEnable(true);
                    findViewById(R.id.button2).setEnable(true);
                                             ....
                }

                public void onAnimationRepeat(Animation animation) {

                }

                public void onAnimationStart(Animation animation) {

                }

            });

 l.startAnimation(l);

你觉得怎么样?

我就是这么说的,注册一个AnimationListener,在动画完成时提醒你。完成后,允许再次单击按钮。这就是我要说的,注册一个AnimationListener,在动画完成时提醒您。完成后,允许再次单击按钮。效果非常好!我将侦听器设置为startAnimation方法中的最后一个动画,效果非常好。谢谢,很好用!我将侦听器设置为startAnimation方法中的最后一个动画,效果非常好。谢谢