I think perhaps I was not too clear... what I was trying to do was have the backgroundProc do some work which would come up with some values and the UI would then be updated to show these values.
As an example I would have an app that would retrieve some data from the web and then update the GUI... but this retrieve operation would not occur on the UI thread.
Hope this makes sense.
What I have now (with thanks to your code) is the following. This seems nicer I think.
Using java Syntax Highlighting
- private Runnable doBackgroundProc = new Runnable(){
- private String strTest = null;
- public void run(){
- try{
- // Do some Fake-Work
- Thread.sleep(2000);
- } catch (Exception e) { }
- strTest = "foobar";
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- TextView tvBal = (TextView)findViewById(R.id.txtTest);
- tvBal.setText(strTest);
- myProgressDialog.dismiss();
- }
- });
- }
- };
Parsed in 0.032 seconds, using GeSHi 1.0.8.4




