Problem with display multiple Toast in order one after another

前端 未结 4 511
心在旅途
心在旅途 2020-12-18 03:22

sorry for my bad English.
i want show two toast in order, in other word when first toast duration is over second toast appear.
this is my code :

Toas         


        
4条回答
  •  既然无缘
    2020-12-18 03:56

    This should help you :

    Toast.makeText(this, "Show toast 1", Toast.LENGTH_SHORT).show();
        new Thread(){
            @Override
            public void run() {
                try{
                    sleep(Toast.LENGTH_SHORT); // sleep the time first toast is being shown
                    Toast.makeText(this, "Show toast 2", Toast.LENGTH_SHORT).show();
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
        }.start();
    

提交回复
热议问题