Code
final Handler handler = new Handler();
final int delay = 1000; //milliseconds
handler.postDelayed(new Runnable(){
public void run(){
if (Seen==1){
holder.messageText.setBackgroundResource(R.drawable.text_background2);
}else{
holder.messageText.setBackgroundResource(R.drawable.text_background1);
}
handler.postDelayed(this, delay);
}
}, delay);
Problem
I want this code to execute every second so i put it inside a simple Handler... textBackground1 in resource file is BLUE and textBackground2 in resource file is GREEN... The value of SEEN is NOT 1 but when the activity starts and the code executes... For 1 second it will show green but after one second it turns BLUE even though the value of SEEN is NOT 1... why is this happening? I think im missing something in the handler or the IF statement... Can someone please help me out
Aucun commentaire:
Enregistrer un commentaire