2016-10-23 4 views
0

AnimationListener에서 동일한 지속 시간을 사용하여 두 애니메이션을 구별하는 방법을 알고 싶습니다. 난 그냥 선언 할 수 있습니다 알고 있지만 나는 이런 식으로 뭔가를 원AnimationListener에서 2 개의 애니메이션 차이점

animation1.setAnimationListener(new Animation.AnimationListener() { 
     @Override 
     public void onAnimationStart(Animation animation) { 

     } 

     @Override 
     public void onAnimationEnd(Animation animation) { 

     } 

     @Override 
     public void onAnimationRepeat(Animation animation) { 

     } 
    }); 

을 그리고 나서 개별 애니메이션 청취자의 결과로 애니메이션 2와 동일한 기능을 수행 할 수 있습니다 (정확히 애니메이션이 ID가 없기 때문에) onAnimationEnd 마음을하시기 바랍니다는 :

public class example implements Animation.AnimationListener{ 
@Override 
public void onBackPressed() { 
    if(detallesvis) { 
     lldetalles.startAnimation(disappear); 
    } 
    else{ 
     finish(); 
    } 
} 

@Override 
public void onAnimationStart(Animation animation) { 

} 

@Override 
public void onAnimationEnd(Animation animation) { 
    if (animation.getId()==animation1.getId())/* please note that animation.getId() function doesn't exist, it is just an example */ { 
     dostuff(); 
    } 
    if (animation.getId()==animation2.getId()){ 
    } 
} 

@Override 
public void onAnimationRepeat(Animation animation) { 

} 

} 

나는 (가능한 경우) 그러나 나는 청소기 접근을하고 싶습니다 ... animation.getduration()를 각 애니메이션에 다른 기간을 설정하고 비교함으로써이 문제를 해결했다.

답변

1

는 애니메이션

@Override 
public void onAnimationEnd(Animation animation) { 
    if (animation == animation1) { 
     dostuff(); 
    } 

    if (animation == animation2) { 
    } 
} 
+0

어떠한 방식으로 개체를 같음 : 오! 고맙습니다! – LuisE

관련 문제