AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("This is Dialog");
dialog.setMessage("something import.");
dialog.setCancelable(false);
dialog.setPositiveButton("OK", new DialogInterface.OnClickLinstener(){
@Override
publlic void onClick(DialogInterface dialog, int which) {
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListenser() {
@Override void onClick(DialogInterface dialog, int which) {
}
});
dialog.show();
7. ProgressDialog
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setTitle("This is a Progressdialog");
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(true);
progressDialog.show();
#如果设置setCancelable(false),要通过dismiss方法来关闭对话框