0

Im a beginner in Android. I would like "freeze" my app (I mean, the user can't do any action) when I must do some operation. By example, I delete all row of one my SQLiteBase's table..during this process, I would like show a progressbar and the user can't do anything before the end.

I know (a little) the progressbar mechanism and the AsyncTask but I find it's a heavy solution.. there is a better simpler solution/practice ?

4

1 回答 1

2

In general, freezing is not a recommended thing and you should always try to allow the user to cancel or go back. It's annoying to wait for operations to finish. More info can be read here.

However, sometimes when you must, you must...

In short, this is how you show a ProgressDialog :

ProgressDialog progressDialog = ProgressDialog.show(this, "dialog title",
"dialog message", false);

(the "false" value is so that the user won't be able to cancel it using the back button)

Then, when you need to dismiss it (upon onPostExecute if you use an AsyncTask), you simply call :

progressDialog.dismiss();
于 2013-03-30T11:27:30.420 回答