0

I'm using a AsynTask and when I go into the processing, which is fetching some info off a webserver I want to display a loading dialogue. Currently I have a Progress spinner which I make visible on onPreExecute but I wanted to put the rest of the UI out of focus whilst it does this.

What is the correct way to do this, should I be using a pop-up type of dialogue instead of just a progress bar?

James MV
  • 8,569
  • 17
  • 65
  • 96

2 Answers2

1
...but I wanted to put the rest of the UI out of focus whilst it does this.

I have a good idea here why don't blur the window of your app to have the effect you need

      WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();  
      lp.dimAmount = 0.0f;  
      dialog.getWindow().setAttributes(lp);  
      dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND)

How to blur/dim an activity


or by using ProgressDialog example of using ProgressDialog:

      ProgressDialog pd = new ProgressDialog(MyApp.this);
      pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
      pd.setMessage("Working...");
      pd.setIndeterminate(true);
      pd.setCancelable(false);
Community
  • 1
  • 1
Ahmad Kayyali
  • 8,233
  • 13
  • 49
  • 83
  • +1 for ProgressDialog. Unfortunately, `FLAG_BLUR_BEHIND` [doesn't work](http://stackoverflow.com/questions/10372404/alternative-to-flag-blur-behind-in-android) for some versions. – Geobits Feb 26 '13 at 19:00
  • 1
    Ha, I didn't realize until after I commented that I was out of votes for the day. Will fix when I can. – Geobits Feb 27 '13 at 20:48
0

You can sue dialogs there yu can make your custom one with spinner and text and set it MY_DIALOG.setCancelable(false) until it finish loading the data.

Rotary Heart
  • 1,899
  • 3
  • 29
  • 44