Hi everyone.
I'm trying to automatically switch between two views on the screen; as part of a game, when the user hits the right button, the view needs to switch to display the result, and then automatically return after (say) 5 seconds. I've tried various things, but none of them seem to work as advertised. Currently I'm using ViewSwitcher, with the two views set up in xml; and using the following to switch:
try{
swap.showNext();
Thread.sleep(1000);
Log.d("GRT:","In here");
}
catch (InterruptedException e){}
finally{
Log.d("GRT:","In here2");
swap.showPrevious();
}
swap is the ViewSwitcher set up with two views.
To my understanding, this should switch views, wait for 1000 ms, then switch back again. Logcat shows that the code is entering the try and finally blocks, with an appropriate pause between them (I get the messages in the adb logcat file) but the display doesn't change. Switching manually (just calling swap.showNext()) _does_ change the display, so AFAICT its not related to the actual View being displayed.
Any suggestions as to what I am doing wrong gratefully received.
I'm trying to automatically switch between two views on the screen; as part of a game, when the user hits the right button, the view needs to switch to display the result, and then automatically return after (say) 5 seconds. I've tried various things, but none of them seem to work as advertised. Currently I'm using ViewSwitcher, with the two views set up in xml; and using the following to switch:
try{
swap.showNext();
Thread.sleep(1000);
Log.d("GRT:","In here");
}
catch (InterruptedException e){}
finally{
Log.d("GRT:","In here2");
swap.showPrevious();
}
swap is the ViewSwitcher set up with two views.
To my understanding, this should switch views, wait for 1000 ms, then switch back again. Logcat shows that the code is entering the try and finally blocks, with an appropriate pause between them (I get the messages in the adb logcat file) but the display doesn't change. Switching manually (just calling swap.showNext()) _does_ change the display, so AFAICT its not related to the actual View being displayed.
Any suggestions as to what I am doing wrong gratefully received.