-1

I'm trying to edit my UI textview but thread doesn't finished loading when view is already rendered, and if I try to edit my textView inside thread I'm getting this error Only the original thread that created a view hierarchy can touch its views. This is my code:

Thread dw= new Thread() {
            public void run() {
                try {
                    s = getData();
                }
                catch (Exception e) {
                    s = "Error";
                    Log.i("Error",e.toString());
                }
            }
        };

        dw.start();
user47823
  • 49
  • 1
  • 6

1 Answers1

0
runOnUiThread(new Runnable() {
     @Override
     public void run() {

         // code that update the textview

     }
});
Matias Elorriaga
  • 8,880
  • 5
  • 40
  • 58