问题描述
我用下面的code创建一个内):
I'm using the following code to create a ProgressDialog (inside my Activity):
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_LOOKUP:
return new ProgressDialog(this, ProgressDialog.STYLE_SPINNER);
}
return null;
}
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
switch (id) {
case DIALOG_LOOKUP:
dialog.setCancelable(true);
dialog.setTitle(R.string.dialogLookup_title);
((ProgressDialog)dialog).setMessage(getResources().getString(R.string.dialogLookup_message));
dialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
Toast.makeText(MyActivity.this, "canceled", Toast.LENGTH_SHORT).show();
}
});
break;
}
}
的问题是,它实际上并不设置标题,并把它在一些奇怪双框
The problem is that it isn't actually setting the title and is putting it in some weird double-box.
它给我这样的:
但我期待这样的东西更多:
but I'm expecting something more like this:
任何想法?
推荐答案
我只是想你的样品,它似乎从 ProgressDialog.STYLE_SPINNER
更改为 ProgressDialog.STYLE_HORIZONTAL
固定怪异的双盒的问题。
I just tried your sample and it seems changing from ProgressDialog.STYLE_SPINNER
to ProgressDialog.STYLE_HORIZONTAL
fixed the weird double-box problem.
和它也显示标题和文本。
And it also displays the title and text.
编辑:
您逝去的 ProgressDialog.STYLE_SPINNER
在 ProgressDialog
构造。
从文档,第二个参数是一个主题ID。
From the doc, the 2nd argument is a theme id.
您必须创建一个 ProgressDialog
对象,并使用 setProgressStyle
到 ProgressDialog。 STYLE_SPINNER
You will have to create a ProgressDialog
object and use the setProgressStyle
to ProgressDialog.STYLE_SPINNER
case DIALOG_LOOKUP:
ProgressDialog pdlg = new ProgressDialog(this);
pdlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
return pdlg;
这篇关于使用ProgressDialog与onCreateDialog / $上的问题P $ ppareDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!