java [Alert Dialog] Alert对话框使用构建器模式#android_snippet #android创建

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java [Alert Dialog] Alert对话框使用构建器模式#android_snippet #android创建相关的知识,希望对你有一定的参考价值。

// this is a context
AlertDialog.Builder builder = new AlertDialog.Builder(this);
// Check other builder methods like setCancelable, setIcon..
builder.setTitle("Set Title");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
	public void onClick(DialogInterface dialog, int id) {
		// do something
  	}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
	public void onClick(DialogInterface dialog, int id) {
    	// do something
    }
});
AlertDialog dialog = builder.create();
dialog.show();

以上是关于java [Alert Dialog] Alert对话框使用构建器模式#android_snippet #android创建的主要内容,如果未能解决你的问题,请参考以下文章