Search code examples
androidandroid-layouttextviewandroid-orientation

textview is cleaned after rotation in Android 4.0 but not in Android 2.0 and 3.0


I have three include other layout (IOL) to include layout with textviews and data in them. Also the background color of the textview changes depending if a related checkbox is checked or not. It happens that if I change device orientation all data and checkboxe states are cleaned, the textview only show the hint text and the background color is conserved. I mention that each IOL include the same layout, but the data in them are accordingly loaded after user selection. I don't understand why this issue occurs for android 4.0 (and up I think, I didn't test yet) but it doesn't for android 2.X and 3.X. My manifest file has:

<activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" 
        android:configChanges="orientation">

how can I fix this problem?


Solution

  • try adding this to your manifest, within the relevant activity

    android:configChanges="orientation|keyboardHidden|screenSize|layoutDirection"
    

    I believe it's the 'screenSize' change issue that your dealing with in 4.0 and up.