Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.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
Java 执行动画后,无法单击ImageButton_Java_Android_Animation - Fatal编程技术网

Java 执行动画后,无法单击ImageButton

Java 执行动画后,无法单击ImageButton,java,android,animation,Java,Android,Animation,在android应用程序中,我在ImageButton上实现了动画。动画完成后,按钮保持在最后一帧,但只能在其初始位置单击,我在main.java活动中通过这些代码行实现了BounceInterpolation动画 TranslateAnimation translation; translation = new TranslateAnimation(0f, 0F, 0f, 200); translation.setStartOffset(150); translation.setDuratio

在android应用程序中,我在
ImageButton
上实现了
动画。动画完成后,按钮保持在最后一帧,但只能在其初始位置单击,我在main.java
活动中通过这些代码行实现了
BounceInterpolation
动画

TranslateAnimation translation;
translation = new TranslateAnimation(0f, 0F, 0f, 200);
translation.setStartOffset(150);
translation.setDuration(100);
translation.setFillAfter(true);
translation.setInterpolator(new BounceInterpolator());
mTourButton.startAnimation(translation);
我不知道如何更新
ImageButton
参数。大多数解决方案都是针对xml实现的动画。我没有找到任何解决办法。我现在累了,请帮帮我。

尝试使用
onTouch()
来处理您的点击

imageButton.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        switch(event.getAction())
        {
            case MotionEvent.ACTION_UP :
            {
            // Do whatever you want here.
            }
        return true;
    }
});

应该可以了。

最好在
XML
中添加
onClick

 <ImageButton
    android:onClick="doSomethingMethod"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton"
    android:layout_above="@+id/imageView"
    android:layout_centerHorizontal="true" />

doSomethingMethod
上的
ALT+ENTER
,并在“活动”中按
创建“doSomethingMethod(视图)”

这将在
活动中创建类似
onClickListener
的方法


希望有帮助

看看这个:自从我提出这个问题以来,我已经尝试了所有列出的3-4种解决方案,但是我只想将参数更新到动画的最后一帧。我认为setLayoutParams()方法可能会有所帮助,但我甚至不知道应该传递什么作为参数。