R.layout.layout_insert_dialog自定義佈局java
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() { @Override public void onClick(DialogInterface object, int id) { // TODO Auto-generated method stub if(id == object.BUTTON_POSITIVE){ }else{ object.cancel(); } } };
注意:dialog控件的初始化在調用dialog的時候進行,不要再Activity初始化的時候進行android