E.g。
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setView(someView);
AlertDialog dialog = builder.create();
dialog.show();
... then later ...
dialog.setView(someOtherView);
代码执行时没有错误,但是对话框中没有替换视图。我做错了还是不可能?
答案 0 :(得分:3)
我认为警告对话框构建器不会以传统方式构建警报对话框,以便与所有版本的android兼容,因此您需要更新内容视图。
Dialog.setContentView(View view)
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setView(view);
AlertDialog alertDialog = builder.create();
alertDialog.show();
然后再
alertDialog.setContentView(newView);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setView(view);
AlertDialog alertDialog = builder.create();
alertDialog.show();
然后再
alertDialog.dismiss();
AlertDialog.Builder updatedBuilder = new AlertDialog.Builder(context);
updatedBuilder.setView(updatedView);
AlertDialog updatedAlertDialog = builder.create();
updatedAlertDialog.show();
答案 1 :(得分:-1)
不,这是不可能的。尝试关闭警告框并设置视图并再次显示。