开发者

Custom progress dialog showing error

开发者 https://www.devze.com 2023-03-16 00:47 出处:网络
I have an application in which i have to show a progress dialog without the title and message. I only need to show the progressbar animation that comes, but in the center.

I have an application in which i have to show a progress dialog without the title and message. I only need to show the progressbar animation that comes, but in the center.

I am trying to put the following code:

        ProgressDialog pd = new ProgressDialog(this);
    ProgressBar pb = new ProgressBar(this);
    pd.setContentView(R.layout.customprogressdialog);
    pd.show();

but i am getting the error th开发者_运维问答at request Feature must be called before `setContentView'. i have tried doing this also but still i am getting an error.

How do i achieve what i want? What is the logic behind calling requestfeature before setcontentview?

thank you in advance.


Don't use a ProgressDialog if that's not what you need. If you want to give a dialog a custom layout, start from scratch with a Dialog or AlertDialog. I think that will fix your problem.


Your issue is that some part of the work done by the show method on the dialog object calls requestWindowFeature: without digging much deeper into the Android platform's guts it is going to be rather hard to tell where exactly that takes place.

You are better served just creating your own Dialog class with your custom layout and adding a method to set the progress bar value.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号