Clarification: Orientation Change


I was surprised to find that changing the orientation of the phone kept the list in the correct position. I’ve mostly only changed a couple of things along the way but I don’t remember ever handling orientation change for CrimeListFragment/CrimeListActivity. Is their somewhere in the book before chapter 10 where this is handled or is it handled by the RecyclerView or Fragment class?


Views also have the ability to save their state (similar to how you can use onSaveInstanceState in activities and fragments). So, the RecyclerView is saving its scroll position across a configuration change.

You can also see this state saving in action with the EditTexts in CriminalIntent. If you type in some text and rotate, the text will be automatically remembered.