0

I have a EditText object created in the main activity in onCreate. I need to be able to change the layout parameters from a SurfaceView thread. Currently I am getting this error:

android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

I also tried setting the layout parameters from a UIHandler but I get the same error. I am really new to Android dev, so I would greatly appreciate any suggestions. Thanks!

Jeshua Lacock
  • 5,730
  • 1
  • 28
  • 58

1 Answers1

3

In general you can use runOnUiThread to update the UI from a different thread. e.g.

runOnUiThread(new Runnable() {
  public void run() {
    textView.setText("Hello");
  }
});
chiuki
  • 14,580
  • 4
  • 40
  • 38