I am able to now change an image when pressing OnTouch, for example I press image1 make it invisible and show the one i have underneath it…
Now i want to change an image on runtime, basically I have an array if array[i] = 5; then i want to make image5 invisible?
How can I do this?, I tried it with a
try{
Thread.sleep(2000);
}
catch
{
}
and it blacks out the screen and then shows the backgroung after 2 seconds but i never see the image get invisible;
i would like to be able to do something like this
for(int i=0;i < array.length; i++)
{
if(array[i] == 1)
{
try
{
Thread.sleep(1000);
ImageView image = (ImageView)findById(myImage01);
image.setVisibility(View.INVISIBLE);
Thread.sleep(1000);
image.setVisibility(View.VISIBLE);
}
catch(InterruptedException e)
{
}
}
}
You get the idea… right now if i do this it will black out the screen and then return to the main layout and do nothing 🙁
Thank you in advance
By the way I am new in Android (please consider 🙁 )
Thread.sleep() is a bad idea because it halts the thread. So if it is the UI-thread, it can not refresh the screen anymore. That’s probably what you observe. Use something like