I get an error when a run this code, every time I set a time on sleep method I get an error and its close the application.
im = (ImageView) findViewById(R.id.imag1);
Thread t = new Thread() {
public void run() {
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
im.setImageResource(R.drawable.primeiro_misterio_gozoso07);
}
}
};
t.start();
How can I fix it?
You cannot access the ui from a non ui thread, you can accomplish the same using a handler..