如何使用RxJava不断更新UI



我试图不断更新UI,但它不工作,我想知道如何使用RxJava

实现相同的功能
TextView textView = findViewById(R.id.textView);
boolean stop = false;
count = 0;
while (true) {
textView.setText(String.valueOf(count));
count++;
if (stop) break;
}
// 'stop' variable will be true, after the response from the server.

你可以使用下面提供的答案:https://stackoverflow.com/a/38607323/6704680

或者你也可以使用CountDownTimer:

CountDownTimer counter = new CountDownTimer(10000, 1000) {
public void onTick(long millisUntilFinished) {
// this happens every 1000ms
}
public void onFinish() {
// this happen after 10seconds or 10000ms
}
};
counter.start();

,你可以随时停止定时器使用:

counter.cancel();