maf*_*oso 4 video android handler android-camera2
我想使用来打印当前秒handler。我精确地录制了视频,10 seconds并且想要设置TextView每秒的文本。
录制10秒的工作原理如下:
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
stopRecordingVideo();
}
}, 11000); // don't know why 11000 but it only works this way
Run Code Online (Sandbox Code Playgroud)
10秒钟后,该方法stopRecordingVideo()将执行。那么,如何每秒更改TextView的文本呢?
工作答案:
int t = 0;
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
t++;
textView.setText(getString(R.string.formatted_time, t));
if(t<10) {
handler.postDelayed(this, 1000);
}
}
}, 1000);
Run Code Online (Sandbox Code Playgroud)
其中formatted_time是这样的:
<string android:name="formatted_time">%d seconds</string>
| 归档时间: |
|
| 查看次数: |
4506 次 |
| 最近记录: |