Update: This post was from when I studied android with Android 2.2, be sure to check if it is compatible with the api level you are working with.
I’m ready to get around a lot about how to load the progress bar using a timer, I tried to use methods, but I always got a pointer exception and when I tried to start the application when loading, it crashed.
My question is: lol did anyone come across any tutorials or examples on how to do this? I think that all I need is a while loop, but I have not yet seen that this is done on a timer. I'm a complete noob, but slowly but surely studying
My timer
final Timer t = new Timer();
t.schedule(new TimerTask() {
public void run() {
d.dismiss();
t.cancel();
}
}, 7000);
This is the one I was trying to find, but I think I did more damage than good with it.
isRunning = false;
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
total = total - 1;
String perc = String.valueOf(total).toString();
a.setText(perc + " SECONDS until close");
bar.incrementProgressBy(25);
}
};
super.onStart();
bar.setProgress(0);
Thread background = new Thread(new Runnable() {
public void run() {
try {
for (int i = 4; i < 20 && isRunning; i++) {
Thread.sleep(1000);
handler.sendMessage(handler.obtainMessage());
}
} catch (Throwable t) {
}
}
});
isRunning = true;
background.start();
, - , , , , ,
tahnks