Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus Player | Nexus 9
test: Reply
LinkBack Thread Tools
Old December 2nd, 2010, 05:16 PM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Dec 2010
Posts: 1
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Notsure Problems with ViewSwitcher

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:

Log.d("GRT:","In here");

catch (InterruptedException e){}
Log.d("GRT:","In here2");

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.

grtabor is offline  
Reply With Quote
sponsored links
Old December 3rd, 2010, 05:10 PM   #2 (permalink)
Senior Member
jonbonazza's Avatar
Join Date: Jul 2010
Gender: Male
Posts: 1,935
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 482 Times in 294 Posts

Try implementing a timer instead of Thread.sleep().
jonbonazza is offline  
Reply With Quote

Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -5. The time now is 03:52 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.