开发者

Prevent android ProgressDialog from blackening entire screen

In the android application that I am building, there are two Views, one below the other. The top one is a Login view, where I have a login form and a submit button, and there is a WebView below it.

I have implemented an AsyncTask when the login button is clicked and the request is sent to the server for login authentication. In the AsyncTask's onPreExecute() method, I create a ProgressDialog and show it. When there is a response from the server, and the login is authenticated, I dismiss the ProgressDialog in the onPostExecute() method of the AsyncTask.

The problem is that during the time the ProgressDialog is 开发者_如何学编程displayed, the entire screen is blackened out and does not respond to any touch. In the application that I am building, it is desired that the WebView below the Login view remains responsive to touches even when the ProgressDialog is being displayed (and the whole screen does not get blackened, only the Login view gets blackened).

Is there a way to do this? (All I need is a spinner kind of object to inform the user that some server authentication is taking place).

The following is some pieces of code from the application.

 private class LoginProgressAsyncTask extends AsyncTask<Void, Void, String>{

        private ProgressDialog dialog  ;

        protected void onPreExecute() {             
            dialog = ProgressDialog.show(context , null, "Verifying Login. Please wait...") ; 


        }

        protected void onPostExecute(String result) {
             if (dialog.isShowing()) {
                    dialog.dismiss();
             }
    }


Then why are you using a ProgressDialog? Just add a Progress Bar to your layout and work with it the same way you're doing it with the dialog. Every dialog blackens the screen by default, it just comes from the logic of dialogs.


http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ProgressBar1.html Here is the example of progressbar usage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜