I have a problem with a textview. When I change the text value with settext, the old value doesn't desapear and the new value is drawn over. So after a few seconds, it's completely illegible. I don't know how to name this bug in english, it's why i post you the folowing screenshot (edit : i can't post it)
My source code :
public class AlarmActivity extends Activity {
int tempsRestant;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm_pad);
startCountdown();
}
void startCountdown(){
//final View view=findViewById(R.layout.activity_alarm_pad).getRootView();
//final View view=((ViewGroup)findViewById(R.layout.activity_alarm_pad)).getChildAt(0);
final View view=this.findViewById(android.R.id.content);
new CountDownTimer(59000, 1000) {
TextView mTextField = (TextView) findViewById(R.id.countdown);
public void onTick(long millisUntilFinished) {
tempsRestant = (int)millisUntilFinished/1000;
mTextField.post(new Runnable() {
public void run() {
mTextField.setText("00:" + tempsRestant);
((View)mTextField.getParent()).invalidate();
}
});
//runOnUiThread(updateTimer());
}
public void onFinish() {
mTextField.setText("Systeme actif");
}
}.start();
}
}
I have tried a lot of things with .invalidate() (on the root View, on the parent view), but i always have the same bug...
In fact, i don't understand if it's a problem with the view refresh or with the threads (the countdown thread).