简体   繁体   中英

Prevent Activity from restarting on rotating the screen

My app is a simple form. I use TableLayout , and have a lot of rows set to visibility="gone" . As user starts filling out the form, more and more rows become visible. But the problem is that the very second screen rotates from portrait to landscape or from landscape to portrait, the whole form resets, and all the fields that were visible become invisible. Is there any way to prevent this from happening?

Thanks in advance to anyone who helps :)

Add this line to your Manifest.xml file, this will prevent of calling onCreate() when screen rotates.

<activity android:name=".yourActivity" android:configChanges="keyboardHidden|orientation">

Version above Android 3.2, you also need to add "screenSize":

<activity android:name=".yourActivity" android:configChanges="keyboardHidden|orientation|screenSize">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM