Code example for AlertDialog.Builder

Methods: create, setMessage, setNegativeButton, setPositiveButton, setTitle

0
	 
	/** 
	 * 提示用户是否保存对话框 
	 */ 
	public void showConfirmSave(){ 
		AlertDialog.Builder builder=new Builder(this);
		builder.setMessage("是否保存新的用户名或密码。");
		builder.setTitle("温馨提示:");
		builder.setPositiveButton("保存", new OnClickListener() {
			@Override 
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
				saveNewPersonInfo(); 
				finish();
			} 
		}); 
		builder.setNegativeButton("不保存", new OnClickListener() {
			@Override 
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
				finish();
			} 
		}); 
		builder.create().show();
	} 
 
	/** 
	 * 保存新的用户信息 
	 */ 
Stop searching for code, let great code find you!  Add Codota to your java IDE