2012-03-14 19 views
2

アニメーションの時間(out1)の間、別のアクティビティ(secondclas)への処理を待機するには、このボタンが必要です。どのようにコード化するのですか?クリック時 - 時間の経過後に別のアクティビティを開始する

button1.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 
      image1.startAnimation(out1); 
      Intent Intent = new Intent(view.getContext(), secondclass.class); 
      startActivityForResult(Intent, 0); 
     } 
    }) ; 

答えて

2

Animation.AnimationListener()をご覧ください。 onAnimationEnd(...)メソッドを実装し、そこで新しいアクティビティを起動することができます。

0

out1.getDuration()でアニメーションの時間を取得できます。インテントは、遅延ハンドラを使用してその時間後に開始することができます。遅れハンドラを起動する方法について

詳細はここで見つけることができます:wait t time before launch an action?

2

あなたはこのようAnimationListener使用することができます。

button1.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 
      out1.setAnimationListener(new AnimationListener() { 
       public void onAnimationStart(Animation animation) { 
       } 

       public void onAnimationRepeat(Animation animation) { 
       } 

       public void onAnimationEnd(Animation animation) { 
        Intent Intent = new Intent(view.getContext(), secondclass.class); 
        startActivityForResult(Intent, 0); 
       } 
      }); 
      image1.startAnimation(out1); 
     } 
    }) ; 
+0

を感謝、それは動作します:) – Tytanit

関連する問題