2016-11-26 9 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

왕! 감사! 나는 지금 '실행'의 요점을 가지고 .. :) –