Back

android 中使用 类似于 js 的 alert ( AlertDialog )

发布时间: 2017-03-05 07:46:00

参考:  http://stackoverflow.com/questions/26097513/android-simple-alert-dialog

代码如下:

        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
        alertDialog.setTitle("Alert");
        alertDialog.setMessage("Alert message to be shown");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        alertDialog.show();

记录它完全是因为 android  不太好理解, 额, alert('hi') 的事儿,在android中搞得如此啰嗦。 

老年人的笔记。

Back