Friday, July 30, 2010

[android-developers] User thread to update UI but still come after, can anyone look at this code and help me?

Hi,
I'm trying to learn AsyncTask and Thread but Thread first...
I am trying to display a Dialog before "DoSomeTask()" but seems like
the Dialog always come after DoSomeTask().
Did I do something wrong here?

Thanks.

--- code---

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

mainProcessing();
DoSomeTask();
}

private void mainProcessing() {
Thread thread = new Thread(null, doBackgroundThreadProcessing,
"Background");
thread.start();
}

private Runnable doBackgroundThreadProcessing = new Runnable() {
public void run() {
backgroundThreadProcessing();

}
};

private void backgroundThreadProcessing() {
handler.post(doUpdateGUI);
}

private Runnable doUpdateGUI = new Runnable() {
public void run() {
updateGUI();
}
};

private void updateGUI() {
final ProgressDialog dialog = new ProgressDialog(CloseVault.this);
dialog.setMessage("Please wait...");
dialog.show();
}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate