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.
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?
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();
}
Thanks!