I have a simple android app with a button who have the text HELLO. If i do not push this button after 10 seconds i want the text to be WAIT. Can someone help me? Thanks
Asked
Active
Viewed 1,353 times
1
-
1in that u have to use timer.... by using timer u can set button text WAIT after 10 Sec..... – Mitesh Jain Oct 18 '11 at 10:15
5 Answers
1
check this timer task for 10 seconds ...button.setText("Wait...");
http://developer.android.com/resources/articles/timed-ui-updates.html

Samir Mangroliya
- 39,918
- 16
- 117
- 134
1
use this code
handler = new Handler();
handler.postDelayed(changeFunction(), 10*1000);
write above in onCreate()
private Runnable changeFunction(){
t = new Timer();
tt = new TimerTask() {
public void run() {
handler.postDelayed(changeFunction(), 10*1000);
button.setText("WAIT");
}
};
return tt;
}

Matthias
- 1,200
- 2
- 13
- 33

RajaReddy PolamReddy
- 22,428
- 19
- 115
- 166
0
This should work
Timer buttonTimer = new Timer();
final Runnable Timer_Tick = new Runnable() {
public void run() {
button.setText("WAIT");
}
};
buttonTimer.schedule(new TimerTask(){
@Override
public void run(){
runOnUiThread(Timer_Tick);
}
},10000);

blessanm86
- 31,439
- 14
- 68
- 79
0
You can use a timed handler message.
Button b;
boolean notPressed;
b.postDelayed(new Runnable() {
@Override
public void run() {
if(notPressed){
b.setText("Wait");
}
}
}, 10000);

Raz
- 8,918
- 3
- 27
- 40