2

I'm using the ProgressDialog in android to prevent the user from, say, pressing a button multiple times while a long task is updating the UI.

My problem is that the ProgressDialog does not seem to show up after awhile, as it seems to be another thread.

In my experiment I called this ProgressDialog show() in an EditText's text changed listener. It still allows me to type in multiple characters in a short period before showing up.

Is there a way I can detect that the ProgressDialog has already started?

Edit 1: This was done on a real device. The code is simply this:

    editText.addTextChangedListener( new TextWatcher() {
            ...
            public void onTextChanged(CharSequence s, int start, int before, int count) {

                    ProgressDialog lock = new ProgressDialog(UIClass.this);
                    lock.show();

        }
            ...
    });

My first assumption was that this would show the dialog immediately after the first character I type, but when I tested by typing multiple characters in a short period it was still possible, and the locking only starts after the 2nd or 3rd character. I am assuming that this is because the ProgressDialog is another thread. I wish to know how to make it properly lock the UI at the exact point I am interested in.

4

0 回答 0