私のアプリケーションは質問/回答アプリケーションであり、ユーザーが質問をし、サーバーがユーザーに質問を送信します。ユーザーが質問を受信すると、ShowQuestionボタンが表示されます。ユーザーがクリックすると、タイマーを開始します。たった36秒で答えるために私はこのように私のxmlでtextViewを構築します
<TextView
android:id="@+id/tvRemaingTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
/>
私のJavaアクティビティでは、これを作成します
TextView remaingTimer;
CountDownTimer timer;
private void initialize() {
remaingTimer=(TextView)findViewById(R.id.tvRemaingTime);
}
ユーザーがShowQuestionをクリックすると、これを作成します
timer =new CountDownTimer(360000,100) {
public void onTick(long millisUntilFinished) {
remaingTimer.setText(millisUntilFinished+"");
}
public void onFinish() {
remaingTimer.setText("finish");
}
};
timer.start();
しかし、それは何も印刷しません、私は何を間違っているのですか?
ノート
私はAsyncTaskを使用して、次のようにサーバーから質問を取得しています。
public class getQuestionFromServer extends
AsyncTask<String, Integer, String[]> {}
ただし、ShowQuestionボタンが表示されないため、textViewには影響しません。それ以外の場合、ユーザーはサーバーから質問を受け取ります。