2016-11-26 4 views
0

私はGifImageButtonビューを持っています。アニメーションを開始してから、アクティビティを再開したい。アクティビティを再開する前にアニメーションを遅らせてください。

問題は、アクティビティを再開する前にアニメーションを3秒間持続させたいということです。

どうすればいいですか?

が、これは私のコードです:

myGifImageButton.setImageResource(R.drawable.animation); 
Intent intent = getIntent(); 
finish(); 
if (intent != null) { 
    startActivity(intent); 
} 

私が読んで、より良い方法は、実行可能なを使用することですので、私はこれを試してみましたが、私はそれを成功しませんでした:

// start the animation 
myGifImageButton.setImageResource(R.drawable.animation); 

// delay the animation 
mHandler = new Handler(); 
final Runnable r = new Runnable() { 
    void run() { 
     handler.postDelayed(this, 3000); 
    } 
}; 
handler.postDelayed(r, 3000); 

// restart the activity 
Intent intent = getIntent(); 
finish(); 
if (intent != null) { 
    startActivity(intent); 
} 

ので、アクティビティを再開する前に、どのようにアニメーションを遅らせることができますか?

答えて

1

Yorの実行可能性が正しくありません - 何もしない同じ実行可能ファイルを継続的に再ポストしています。

は、代わりにこのような何かを試してみてください。

// start the animation 
myGifImageButton.setImageResource(R.drawable.animation); 

// delay the animation 
mHandler = new Handler(); 
final Runnable r = new Runnable() { 
    void run() { 
     // restart the activity 
     Intent intent = getIntent(); 
     finish(); 
     if (intent != null) { 
      startActivity(intent); 
     } 
    } 
}; 
handler.postDelayed(r, 3000); 
+0

王を!ありがとう!私は今 '実行'のポイントを得た.. :) –

関連する問題