我正在try 在Android中生成一个自定义对话框.
dialog = new Dialog(this);
dialog.setContentView(R.layout.my_dialog);
除了对话框的标题外,其他一切都很好.
有什么方法可以隐藏对话框的这一部分吗?
我用AlertDialog试过,但布局似乎设置不正确:
LayoutInflater inflater =
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.map_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view);
// dialog = new Dialog(this);
// dialog.setContentView(R.layout.map_dialog);
dialog = builder.create();
((TextView) dialog.findViewById(R.id.nr)).setText(number);
如果我使用这段代码,我会在最后一行得到一个空指针异常.该对话框不为空,因此我try 检索的文本视图不存在