Having a problem updating UI from a second thread where the first thread works just fine?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

All the UI changes should be done from the same thread or a handler in that thread or from an AsyncTask Check this post to read a little about AsyncTasks in android I am guessing that you did not do the Button declaration right or you are setting the event from another thread. That will give you this error. If you still are struck, then post the relevant code here and I can try to help you better.

All the UI changes should be done from the same thread or a handler in that thread or from an AsyncTask. Check this post to read a little about AsyncTasks in android. I am guessing that you did not do the Button declaration right or you are setting the event from another thread.

That will give you this error. If you still are struck, then post the relevant code here and I can try to help you better.

Appreciate the quick response, there is a ton of code, so I am trying to only post the relevant parts and some explanation. Basically I have a method getWorkouts that goes out to a website, posts some data and returns some XML. That XML is then run through a method called parse which parses the XML and a ListView is updated with the results.

The initial thread I posted above works fine when the page first loads, it defaults to grab the XML for todays date and populates the ListView. The Button works correctly if I don't attempt to use a thread. I get the error when I attempt to run the same methods (getWorkouts, and parse) using a new thread and handler inside the onClickListener.

Here is the button onClickListener not using a thread. BToday. SetOnClickListener(new View.OnClickListener(){ public void onClick(View v) { xmlOut = getWorkouts(todaysDate); parse(xmlOut); } } Here is the code right before the button listener.

Public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout. MyLayout); ...Lots of definitions and such... bToday = (Button) findViewById(R.id.

BToday); todaysDate = getTodaysDate(); final Handler handler = new Handler(){ public void handleMessage(Message msg){ progDialog.dismiss(); parse(xmlOut); } }; progDialog = ProgressDialog. Show(this, "Working...", "Doing stuff..."); thread = new Thread(){ public void run(){ xmlOut = getWorkouts(todaysDate); handler. SendEmptyMessage(0); } }; thread.start(); I moved all the variables up to the class level to see if it was a visibility problem but that didn't seem to help.

Hopefully I asked the question a bit better this time, I can get the thread updating the UI fine with the thread I listed here, but I want to run those 2 methods again in a separate thread since I can't re-use my initial thread when the user clicks a button.

That should not happen unless you are trying to change the UI from another thread. But you clearly say that you do not do that. But it looks like there is some problem with the way the way you are calling it or what ever you are doing in the getWorkouts method.

Can you post the complete code and the error log. – achie Nov 27 '10 at 3:32.

Appreciate the quick response, there is a ton of code, so I am trying to only post the relevant parts and some explanation. Basically I have a method getWorkouts that goes out to a website, posts some data and returns some XML. That XML is then run through a method called parse which parses the XML and a ListView is updated with the results.

The initial thread I posted above works fine when the page first loads, it defaults to grab the XML for todays date and populates the ListView. The Button works correctly if I don't attempt to use a thread. I get the error when I attempt to run the same methods (getWorkouts, and parse) using a new thread and handler inside the onClickListener.

Here is the button onClickListener not using a thread. Here is the code right before the button listener. I moved all the variables up to the class level to see if it was a visibility problem but that didn't seem to help.

Hopefully I asked the question a bit better this time, I can get the thread updating the UI fine with the thread I listed here, but I want to run those 2 methods again in a separate thread since I can't re-use my initial thread when the user clicks a button.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions