I want create some simple animation for my program. There is 4 invisible button, and that I want is when program is started, those button will visible with delay.
Show button 1 -> button 2 -> and so on.
I tried this, but when program running, all button will appear in same time.
try {
((Button) findViewById(R.id.f1)).setVisibility(View.VISIBLE);
Thread.sleep(1200);
((Button) findViewById(R.id.f2)).setVisibility(View.VISIBLE);
Thread.sleep(1200);
((Button) findViewById(R.id.f3)).setVisibility(View.VISIBLE);
Thread.sleep(1200);
((Button) findViewById(R.id.f4)).setVisibility(View.VISIBLE);
Thread.sleep(1200);
} catch (Exception e) {
}
anyone can help me ?
Use a Handler:
private Handler handler;
private void showButtons(){
handler = new Handler();
handler.postDelayed(new Runnable(){
@Override
public void run(){
((Button) findViewById(R.id.f1)).setVisibility(View.VISIBLE);
}
}, 1200);
handler.postDelayed(new Runnable(){
@Override
public void run(){
((Button) findViewById(R.id.f2)).setVisibility(View.VISIBLE);
}
}, 2400);
//etc
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With