为ProgressDialog设置/添加自定义内容视图:必须调用requestfeature()

Iir*_*kka 2 android

所以我想在ProgressDialog中添加一个自定义的imageview:

LinearLayout root = (LinearLayout)findViewById(R.id.root);
ProgressDialog pdialog = new ProgressDialog(context);
pdialog.setTitle("Wait");
pdialog.setMessage("Loading...");
pdialog.addContentView((ImageView)findViewById(R.id.imageV3iew1), root.getLayoutParams());
pdialog.setCancelable(false);
pdialog.show();
Run Code Online (Sandbox Code Playgroud)

它说指定的子节点已经有父节点,我必须首先在父节点上调用removeView.我知道如何创建自定义对话框,但我想将我的imageview直接附加到ProgressDialog.我需要提供哪种功能?

inf*_*l3x 8

我有同样的问题.看看这个解决方案:https://stackoverflow.com/a/10070995/1487456

基本上,你需要在打电话.show()之前打电话.setContentView(),因此也可能.addContentView().

然后,您可以根据需要对布局进行充气并进行自定义.