工具类--一句代码创建对话框

       下面是一个创建对话框的最快捷方法,一句代码搞定

1.无按钮

new AlertDialog.Builder(WebViewActivity.this).setMessage(data).create().show();

2.有按钮

new AlertDialog.Builder(this).setMessage("this is a dialog").setIcon(R.drawable.ic_launcher).setTitle("Exit Dialog")setPositiveButton("exit", new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				Toast.makeText(UpdatePasswordActivity.this, "exit", 0).show();
			}
		}).setNegativeButton("cancle", new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				Toast.makeText(UpdatePasswordActivity.this, "cancle", 0).show();

			}
		}).create().show();


你可能感兴趣的:(工具类,alterDialog)