When I want to setText to a textView, the application force closes and gives me this error:
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
This is a part of my code :
Thread ThreadRecording = new Thread(new Runnable() {
public void run() {
while(recorder)
{
if (body_num = 10)
{
TextView loog = (TextView)findViewById(R.id.textView1);
loog.setText("Total : 10, Thank you");
}
}
}
});
ThreadRecording.start();
There's a button; if the user clicks it, it calls a function to set body_num = body_num + 1
and the thread checks if body_num == 10