0
I’m using the following code
new Thread(new Runnable() {
public void run() {
while (cont < 100) {
cont += 1;
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
progressBar.setVisibility(View.GONE);
}
}).start();
The problem is that when setting Visibility the following error appears
FATAL EXCEPTION: Thread-1087 Process: br.alphatec.ms_cliente_alpha1, PID: 23000 android.view.Viewrootimpl$Calledfromwrongthreadexception: Only the original thread that created a view Hierarchy can touch its views.
And when the code was running like this, but very fast, and if I increase the value(100) that’s in while it stops working
new Thread(new Runnable() {
public void run() {
while (cont < 100) {
cont += 1;
}
progressBar.setVisibility(View.GONE);
}
}).start();