我做这样的事情:
LinearLayout dialogLayout = (LinearLayout) ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.dialog_addeditrecord, null);
然后,我使用dialogLayout调用findViewById()来拉入按钮和其他视图,并设置OnClickListeners等。
然后显示对话框:
builder = new alertDialog.Builder(this);builder.setView(dialogLayout);builder.create().show();



