我是 Xamarin.Android 框架的新手。我正在研究倒数计时器,但无法像javaCountDownTimer
类那样实现。任何人都可以帮我将以下 java代码转换为 C# Xamarin android 代码。
bar = (ProgressBar) findViewById(R.id.progress);
bar.setProgress(total);
int twoMin = 2 * 60 * 1000; // 2 minutes in milli seconds
/** CountDownTimer starts with 2 minutes and every onTick is 1 second */
cdt = new CountDownTimer(twoMin, 1000) {
public void onTick(long millisUntilFinished) {
total = (int) ((dTotal / 120) * 100);
bar.setProgress(total);
}
public void onFinish() {
// DO something when 2 minutes is up
}
}.start();