问题描述
我有这样的机器人活动/一个按钮的布局。当我点击这个按钮,它会打开2纺纱一个DialogFragment。当DialogFragment显示出来,我需要填充这两个纺纱由Web服务返回的项目。因此,在等待的服务来回报,我想在我刚刚开了DialogFragment显示ProgressDialog。
I have this Android activity/layout with a button. When I click this button, it opens a DialogFragment with 2 spinners. When the DialogFragment shows up, I need to populate these 2 spinners with items returned by a web service. So, while waiting for the service to return, I'd like to display a ProgressDialog over the DialogFragment I've just opened.
现在的问题是,我似乎无法使ProgressDialog在DialogFragment的顶部。我可以看到ProgressDialog所显示的DialogFragment的背后,是有可能使ProgressDialog显示了一切?
The problem is I can't seem to make the ProgressDialog on top of the DialogFragment. I can see the ProgressDialog being shown behind the DialogFragment, is it possible to make the ProgressDialog being displayed over everything else?
我的code是这样的:
My code is like this:
public class RegionalFragment extends DialogFragment {
private View view;
private Activity activity;
private Spinner spinner1;
private Spinner spinner2;
private ProgressDialog progressDialog;
public RegionalFragment(Activity activity) {
this.activity = activity;
LayoutInflater inflater = activity.getLayoutInflater();
view = inflater.inflate(R.layout.spinner_selection, null);
this.progressDialog = new ProgressDialog(activity);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder =
new AlertDialog.Builder(activity)
.setTitle(R.string.title)
.setView(view)
.setPositiveButton(R.string.ok, new MyListener(activity))
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
getDialog().cancel();
}
});
progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(1));
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
progressDialog.setMessage("Please wait...");
progressDialog.show();
invokeAsyncWebService();
return builder.create();
}
谢谢!
推荐答案
显然那是一个普遍抱怨的主题与 ProgressDialog
,我建议你尝试一个正常的对话,与创建建筑商和其布局(一个自定义您制作),包括进度条或加载或任何你需要的。这应该解决您的问题。
Apparently thats a widely complained about subject with ProgressDialog
, I suggest you try a normal dialog, created with the builder and whose layout (a custom one made by you) includes the progress bar or loading or whatever you need. This should solve your problem.
这篇关于我怎样才能打开一个ProgressDialog上DialogFragment的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!