0
내가처럼 될 것 '추구'텍스트 만들고 싶어 (안드로이드를) 제대로 작동하지 않습니다. "로드" 을 -> "로드 중 ..."-> "로드 중 ..."미래의 작업은
그런 다음 특정 데이터를 얻으면이 애니메이션 텍스트를 중지하고 텍스트를 "Found"로 설정하십시오.
나는 그런 식으로 구현하는 시도 :
ExecutorService threadPoolExecutor = Executors.newSingleThreadExecutor();
Future textAnimationTaskFuture;
Runnable textAnimationTask;
textAnimationTask = new Runnable() {
@Override
public void run() {
int passedTime = 0;
while(passedTime < 3000)
{
if(passedTime < 1000){
textView.setText("Loading.");
}
else if(passedTime >= 1000 && passedTime < 2000)
{
textView.setText("Loading..");
}else if (passedTime >= 3000)
{
textView.setText("Loading...");
}
passedTime = passedTime + 1;
if(passedTime == 3000)
passedTime = 0;
}
}
};
을 그리고 나서 프로세스 실행됩니다 :
textAnimationTaskFuture = threadPoolExecutor.submit(textAnimationTask);
을 그리고 취소
textAnimationTaskFuture.cancel(true);
textView.setText("Found.);
불행하게도 루프하지 않는 취소시 중지 (true).
디버깅을 시도했지만 불행히도 문제를 찾을 수없는 것 같습니다. 어쩌면 내가 뭔가 잘못하고있는 것 같아요./ – BVtp
흠 ... 여기를 보시면 아마도 도움이 될 것입니다. http://stackoverflow.com/questions/13623445/future-cancel-method-is-not-working – yakobom