Answer the question
In order to leave comments, you need to log in
How to display three or four different Toasts with a pause between them on button click?
Here is the code in the Activity.java file: (tried two different delay mechanisms and it doesn't work)
Variables
public Handler handler;
Button b1;
Далее в onCreate()…
b1 = findViewById(R.id.cast_button);
h = new Handler()
и описание кнопки -
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {//----Здоровье, самочувствие
Toast.makeText(Cast.this, "Начали!!!", Toast.LENGTH_LONG).show();
try {
Thread.sleep(30000);
} catch (Exception xx) {
xx.toString();
}
Toast.makeText(Cast.this, "Середина !!", Toast.LENGTH_LONG).show();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Toast.makeText(Cast.this, "Почти закончили!!!", Toast.LENGTH_LONG).show();
}
},10000);
Toast.makeText(Cast.this, "Закончили!!!", Toast.LENGTH_LONG).show();
}
});//конец кнопки
Answer the question
In order to leave comments, you need to log in
https://developer.android.com/reference/android/os...
further already...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question