2017-02-28 4 views
1

私が持っているのアラートダイアログのアニメーションリスナーを追加し、私は、エントリのカスタムアニメーションを使用します。警告ダイアログ

dialog.getWindow().getAttributes().windowAnimations = R.style.my_animation; 
<style name="my_animation"> 
    <item name="android:windowEnterAnimation">@anim/slider_anim</item>  
</style> 

R.anim.slider_anim.xml 
<?xml version="1.0" encoding="utf-8"?> 
<translate xmlns:android="http://schemas.android.com/apk/res/android" 
      android:fromXDelta="-100%p" 
      android:fromYDelta="0" 
      android:duration=“1500"> 

</translate> 

これは正常に動作しますが、私は検出するために、アニメーションのリスナーを設定する方法を見つけ出すことはできませんアニメーションの終わり。の後に別のビューをアニメーション化する必要があります。ダイアログのアニメーションが完了しました。
は、私はこれを試みたが、アニメーションは全くロードされていません。

Animation animation = AnimationUtils.loadAnimation(root.getContext(), R.anim.slider_anim);  
animation.setAnimationListener(new Animation.AnimationListener() { 
    @Override 
    public void onAnimationStart(Animation animation) { 

    } 

    @Override 
    public void onAnimationEnd(Animation animation) { 
     Log.d(TAG, "onAnimationEnd"); 
    } 

    @Override 
    public void onAnimationRepeat(Animation animation) { 

    } 
}); 
dialog.getWindow().getDecorView().setAnimation(animation);  

私はこれをどのように行うことができますか?

答えて

0

文書Animation.AnimationListener

からonAnimationEnd方法は、アニメーションの終了を通知します。

繰り返しカウントをINFINITEに設定したアニメーションでは、このコールバックは呼び出されません。

ですので、繰り返し回数を確認してください。

@Override 
protected void onAnimationEnd() { 

    //your methods 
} 
+0

アニメーションが2番目のスニペット – Jim

関連する問題