如何获得这些动画开始的视图对象......? [英] How to get View object on which animation was started......?

查看:85
本文介绍了如何获得这些动画开始的视图对象......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪,我开始同样的动画3图像视图(翻译)

I have 3 image view in which i started same animation (translate)

我有动画的听众,在onAnimationEnd(动画动画)的方法,

I have animation listener, in onAnimationEnd(Animation animation) method,

我想知道哪个图像视图动画结束..?

I want to know on which image view the animation is ended..?

从动画对象,我怎么能知道它开始..?

From animation object how can I know in which it was started..?

在此先感谢..!

推荐答案

好了,你可以不知道什么是动画结束了它的对象。该AnimationListener的全部目的是为了听动画,而不是目标。

Well you can not know what is the object on which the animation ended. The whole purpose of the AnimationListener is to listen to the Animation and not to the object.

解决方案

1 - 创建自己的动画类,并保存在它的引用,这是制作动画的对象

1- Create your own Animation class and save in it a reference to the object which is animating.

这将允许你施放动画YourAnimation在功能 onAnimationEnd 并获得借鉴。

This will allow you to cast the Animation to YourAnimation in the function onAnimationEnd and get the reference.

2 - 一个更简单的解决方案是创建你自己的AnimationListener,用于保存动画对象的引用

2- A simpler solution is to create your own AnimationListener that holds a reference of the Object that is animated.

例如:

public class MyAnimationListener implements AnimationListener {
    ImageView view;
    public void setImage(ImageView view) {
        this.view = view;
    }
    public void onAnimationEnd(Animation animation) {
        // Do whatever you want
    }
    public void onAnimationRepeat(Animation animation) {
    }
    public void onAnimationStart(Animation animation) {
    }
}

所以,当你想动画的ImageView的:你做到以下几点:

So when you want to animate your ImageView: You do the following:

MyAnimationListener listener = new MyAnimationListener();
listener.setImage(myImage);

myAnimation.setAnimationListener(listener);

这篇关于如何获得这些动画开始的视图对象......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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