一、在Activity的方法中加入代码
new AlertDialog.Builder(this)
.setTitle("Title")
.setMessage("Message")
.setPositiveButton("OK",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
// continue
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
// do nothing
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();