my application is question/answer application , the user ask for a question , then the server send question to a user, when user receives the question , a ShowQuestion button appears , when user click it , i want to start timer , because a user have to answer in just 36 Second
i build a textView in my xml like this
<TextView
android:id="@+id/tvRemaingTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
/>
and in my Java activity i make this
TextView remaingTimer;
CountDownTimer timer;
private void initialize() {
remaingTimer=(TextView)findViewById(R.id.tvRemaingTime);
}
and when a user click ShowQuestion i make this
timer =new CountDownTimer(360000,100) {
public void onTick(long millisUntilFinished) {
remaingTimer.setText(millisUntilFinished+"");
}
public void onFinish() {
remaingTimer.setText("finish");
}
};
timer.start();
but it doesn’t print anything, what am i doing wrong ?
NOTE
i am using AsyncTask to get question from server like this:
public class getQuestionFromServer extends
AsyncTask<String, Integer, String[]> {}
but i don’t thing it effect on textView because the ShowQuestion button will not appear else a user have got a question from the server
you can use runOnUiThread for updateing TextView from Thread as: