In the second version you try to update the UI from a thread that's
not the UI thread.
This is an example that works:
private void yourMethod() {
final Handler uiThreadCallback = new Handler();
setProgressBarIndeterminateVisibility(true);
final Runnable runInUIThread = new Runnable() {
public void run() {
thingsToDoInUiThread();
setProgressBarIndeterminateVisibility(false);
}
};
new Thread() {
@Override
public void run() {
thingsToDoInSeparateThread();
uiThreadCallback.post(runInUIThread);
}
}
}.start();
}
On Nov 29, 12:49 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Dear all
> I'm having difficulties in ProgressDialog--I've tried out two options
> given below:
>
> Version 1.
> pd = ProgressDialog.show(this, "Please wait", "Fetching data",
> true,false);
> updateUI(this);
> Thread t = new Thread() {
> public void run() {
> pd.dismiss();
> }
> };
> t.start();
>
> Version 2.
> pd = ProgressDialog.show(this, "Please wait", "Fetching data",
> true,false);
> Thread t = new Thread() {
> public void run() {
> updateUI(this);
> pd.dismiss();
> }
> };
> t.start();
>
> In the first case, I get the GUI updated, but the ProgressDialog
> doesn't appear. In the second case, the situation is reversed, with
> the ProgressDialog appearing, but the GUI doesn't appear.
>
> Thanks in advance...any help would be much appreciated.
>
> a.o.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---