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 trialABHISHEK RAI
4,865 Pointschange of state during orientation
why editText retained it's value during screen rotation?Which is contradictory to what we saw in fun facts project.
3 Answers
Ruan Lopes de Souza
4,854 PointsActually on the FunFacts we used TextViews instead of EditTexts.
TextViews values won't be saved automatically different than EditText because on EditText there is a flag called "freezeText' that is set to "true" by default, but you can make the TexView do the same by setting the "freezeText" flag to true via xml android:freezesText="true" or TextView#setFreezesText(true) on the widget. Otherwise you will have to make it manually as it was done on the FunFacts app.
Joe Brown
21,465 PointsIf I remember right, that is just a sort of courtesy the system provides for you since it is such a common thing. It is most likely stored in the savedInstanceState Bundle and restored for you then after rotation/recreation.
Dylan Ali
184 PointsI have the same question too. Don't we name all our view ids "uniquely" in the Fun Facts project ?
vipin tomar
280 Pointsvipin tomar
280 PointsI create a log statement to see what's the value of freezeText attribute in EditText by default and I get a false
Log.d("TAG", mEditText.getFreezesText() + "");
vipin tomar
280 Pointsvipin tomar
280 PointsFor correct information see https://developer.android.com/reference/android/view/View.html#attr_android:saveEnabled