비디오 녹화를위한 응용 프로그램을 만들고 비디오 미리보기를 txtStatus
및 txtTime
레이블로 덮어 썼습니다.GUI 업데이트를위한 타이머 사용 : 왜 작동하지 않습니까?
카메라 버튼은 주기적으로 UpdateGUI
메서드를 호출하는 타이머를 시작/중지합니다. 디버그를 실행하면 타이머가 작동하는 것을 볼 수 있습니다 - 매초 updateGUI
메서드를 호출하지만 메서드는 컨트롤을 업데이트하지 않습니다.
이 문제를 해결하는 방법에 대한 힌트를 얻을 수 있다면 정말 고마워 할 것입니다.
private void startTimer()
{
updateTimer = new Timer("TimerUpdate");
updateTimer.scheduleAtFixedRate(new TimerTask(){
public void run(){
settings.IncreaseRecordingTime();
updateGUI();
}
}, 0, 1000);
}
이것은 updateGUI 방법입니다 :
private void updateGUI()
{
setStatusLabel();
String strTime = settings.GetTimerString(); //strTime changes every second (it works as expected)
txtTimer.setText(strTime);//the text doesn't change!
}
그리고이 호출되는 방법이 타이머를 활성화하는 방법은
: 여기
코드입니다 버튼을 눌렀을 때 :private boolean onCaptureButton()
{
settings.CaptureAction();
videoPreview.setFrameCallback(settings);
updateGUI();//here the function updateGUI() works as expected - it changes the txtStatus text from "Preview" to "Recording"
setTimer();
return false;
}
덧글을 덧붙여서 onCaptureButton()
메서드에서 호출 할 때 updateGUI()
이 작동하는 이유를 모르거나 타이머 메서드 내에서 호출 할 때 작동하지 않습니다.
txtTimer.refreshDrawableState();를 사용하려고했습니다. 하지만 작동하지 않습니다. –