Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting/adding custom content view for ProgressDialog: requestfeature() must be called

Tags:

android

So I would like to add a custom imageview to a ProgressDialog:

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();

It says that the specified child already has a parent and I have to call removeView on the parent first. I know how to create custom dialogs but I would like to append my imageview right to the ProgressDialog. What kind of feature do I need to request?

like image 299
Iiro Krankka Avatar asked Dec 05 '25 10:12

Iiro Krankka


1 Answers

I had the same problem. Check out this solution: https://stackoverflow.com/a/10070995/1487456

Basically, you need to call .show() before you call .setContentView() and therefore probably .addContentView() also.

You can then inflate a layout and customise it however you wish.

like image 157
infl3x Avatar answered Dec 07 '25 22:12

infl3x



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!