0
我想更改CountDownTimer中類變量的值,但它不起作用。下面是一個簡短的例子,它顯示了我的意思:android:更改CountDownTimer中的變量值
public class MainActivity extends Activity {
private int var;
@Override
protected void onCreate(Bundle savedInstanceState) {
.
.
.
var = 0;
tmr = new CountDownTimer(t, 1000) {
public void onTick(long millisUntilFinished) {
var = 1;
}
public void onFinish() {
}
}.start();
}
@Override
public void onLocationChanged(Location location) {
Log.d(tag, var);
}
}
Log.d(tag,var)的輸出;總是爲0,但我想獲得定時器設置的值。
請發佈更多的這個類的代碼。 – JDJ
「CountDownTimer」的構造函數中't'變量的值是什麼? –