如何设置主题ProgressDialog?如何设置、主题、ProgressDialog

2023-09-07 11:14:45 作者:撒浪嘿呦

我想设置progressDialog的主题。要创建它,我用这个code:

I would like to set theme of progressDialog. To create it, I use this code:

progressDialog = ProgressDialog.show(this, "Please Wait", "Loading dictionary file....", true, false);

我不能只是写

I can't just write

progressDialog = new ProgressDialog(...);
progressDialog.(do_sth_with_dialog);
progressDialog.show(...)

因为show()方法是静态的,我收到编译器警告。 有没有办法使用像

because the show() method is static and I get compiler warning. Is there any way to use available constants like

progressDialog.THEME_HOLO_DARK 

设置对话框主题?

to set the dialog theme?

我也想改变对话框的背景,使边角圆(我不想改变的进度是内部progressDialog什么。这里有很多教程,但他们通常描述了如何创建新类扩展progressDialog类。

I would also like to change the Dialog background and make the corners round (I don't want to change anything with the progressBar that is inside progressDialog. There is many tutorials here, but they usually describe how to create new class that extends progressDialog class.

有没有更简单的方法来设置progressDialog主题和背景颜色? 为什么我可以访问常量像progressDialog.THEME_HOLO_DARK,如果我不能使用他们?

Is there easier way to set THEME and BACKGROUND color of progressDialog? Why I can access constants like progressDialog.THEME_HOLO_DARK if I cant use them?

推荐答案

ProgressDialog.show()的静态方法,这样你就不会得到一个类实例 ProgressDialog ,你可以设置属性。

ProgressDialog.show() are static methods, so you don't get a class instance of ProgressDialog that you can set properties on.

要获得 ProgressDialog 例如:

// create a ProgressDialog instance, with a specified theme:    
ProgressDialog dialog = new ProgressDialog(mContext, ProgressDialog.THEME_HOLO_DARK);
// set indeterminate style
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
// set title and message
dialog.setTitle("Please wait");
dialog.setMessage("Loading dictionary file...");
// and show it
dialog.show();