Add positive button to Dialog

后端 未结 3 711
不知归路
不知归路 2020-12-31 15:39

I have a very simple custom dialog and I wan\'t to add a positive button without having to modify the XML file, just like you would do it with an AlertDialog but I don\'t kn

3条回答
  •  生来不讨喜
    2020-12-31 16:40

    You also can use this function

    public void showMessage(String title,String message)
    {
        AlertDialog.Builder builder=new AlertDialog.Builder(this);
        builder.setCancelable(true);
        builder.setTitle(title);
        builder.setMessage(message);
        builder.setPositiveButton("OK", new
                DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
        builder.show();
    }
    

提交回复
热议问题