Problem with display multiple Toast in order one after another

前端 未结 4 522
心在旅途
心在旅途 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 04:17

    Other solution is to use AlertDialog

    createDialog().show();

    with two methods createDialog() and continueDialog()

    public AlertDialog createDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("Toast1")
                .setPositiveButton("Next",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                continueDialog().show();
                            }
                        });
        return builder.create();
    }
    
    public AlertDialog continueDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("Toast2")
                .setPositiveButton("OK",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
    
                            }
                        });
        return builder.create();
    }
    

提交回复
热议问题