• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Problems with ViewSwitcher

grtabor

Lurker
Dec 2, 2010
1
0
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.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones