Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialartemsborets
4,558 PointsText is updated when device orientation changes
Hello
I just test my Fun Facts app on a real device (Samsung Galaxy Tab 3). And I just found that when I change device orientation it makes an app change the orientation too. And as far as orientation changes it resets the text inside the text field to its initial view. Text inside the text label gets as the app is just started.
How can I fix it? How can I make orientation of a layout static? How can I keep the text in case if app's orientation changes? What is the nature of this problem?
Thank You
2 Answers
Rebecca Rich
Courses Plus Student 8,592 PointsBy default, when the screen is rotated your Activity is killed and restarted.
There are a lot of ways to approach this problem. One fix, is that you can simply force the orientation of your app, for example to always be portrait. This can be done by editing your activity in your manifest to include:
android:screenOrientation="portrait"
Another option is to handle the configuration changes yourself. Check out: http://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange
Don't forget to pay attention to the blurb on screen size if you are using a more modern API (API 13+).
artemsborets
4,558 PointsThanks a lot, Rebecca!