2019独角兽企业重金招聘Python工程师标准>>>
R.layout.layout_insert_dialog自定义布局
View mView=LayoutInflater.from(MainActivity.this).inflate(R.layout.layout_insert_dialog, null);
AlertDialog.Builder dialog=new AlertDialog.Builder (MainActivity.this);
dialog.setTitle(R.string.approval_suggestion).setView(mView)
.setPositiveButton(R.string.yes, monClickBtn).setNegativeButton(R.string.no, null).show();
private android.content.DialogInterface.OnClickListener monClickBtn = new android.content.DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface object, int id) {// TODO Auto-generated method stubif(id == object.BUTTON_POSITIVE){}else{object.cancel();}}};
注意:dialog控件的初始化在调用dialog的时候进行,不要再Activity初始化的时候进行