final View DialogView = factory.inflate(R.layout.dialog, null);
AlertDialog dialog1 = new AlertDialog.Builder(Dialog.this)
.setTitle("设置号码")
.setMessage("现在设置的号码是:\n"+name)
.setView(DialogView)//设置样式
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialo, int arg1) {
num2 = (EditText) DialogView.findViewById(R.id.num);
number1 = num2.getText().toString();
}}
DialogView
需要注意使用的是View的id来获取,不然就出现NUll的异常,如下:
参考:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=74810