[Solved] android error :ViewRootImpl$CalledFromWrongThreadException [closed]


Your are touching the views(widgets) in the Non UI Thread.

public class B extends Thread {
    TextView inputtext;
    Activity activity;

    public B(Activity activity, TextView x) {
        inputtext = x;
        this.activity = activity;
    }

    public void run() {
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                inputtext.setText("hero");
            }
        });
    }
}

While starting the Thread

B b=new B(MainActivity.this, inputtext); 
b.start();

4

solved android error :ViewRootImpl$CalledFromWrongThreadException [closed]