T
T
Trader272019-03-07 15:10:09
Android
Trader27, 2019-03-07 15:10:09

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

2 answer(s)
D
davidnum95, 2019-03-07
@Trader27

https://developer.android.com/reference/android/os...
further already...

T
Tiberal, 2019-03-08
@Tiberal

https://developer.android.com/reference/android/os...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question