0

as we know in Android applications we can touch views just from Main/UI Thread and otherwise an CalledFromWrongThreadException throws with below message:

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

but when I touch just 1 time at onCreate(), this Exception does not throw and "Hello Again!" sets on TextView

 TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    tv = findViewById(R.id.tv);

    new Thread(new Runnable() {
        @Override
        public void run() {
            tv.setText("Hello Again!");
        }
    }).start();
}

Do you know why?

beigirad
  • 4,986
  • 2
  • 29
  • 52

0 Answers0