Is It Possible To Wait Until A Toast Has Finished To Resume The Method?
In one of my methods, I have a toast that appears if the user gives the correct input. However, I do not want the next image to display until the toast has finished. If I use Threa
Solution 1:
I don't believe there would be any way to do this with a toast. If you are simply trying to show someone a "You're Correct" Window, I would consider simply using an AlertDialog with a single positive Okay button.
It would even be possible to show a dialog with no buttons, have a non-UI thread sleep for a bit and then dismiss the dialog.
Solution 2:
Create a custom dialog with no buttons and use a handler to both dismiss it after a short time and then show the next image.
Solution 3:
Use a CountDownTimer
with Toast.LENGTH_SHORT
as the time?
public void correction(){
if(correctionBoolean == true){
Toast.makeText(this, "Correct!", Toast.LENGTH_SHORT).show();
new CountdownTimer(Toast.LENGTH_SHORT, 1000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
NextImage();
}
}.start();
}
Post a Comment for "Is It Possible To Wait Until A Toast Has Finished To Resume The Method?"