简体   繁体   中英

Content disappears when I press Ctrl + F11?

I have an option menu, that one of the options, when clicked, starts a new activity for result. So when this activity is destroyed, a get the result and create a table row based on the result in the onActivityResult method and the table row appears in the screen, but when I press Ctrl + F11 , the content is not there. I know that if I create the table row in the OnCreate method, this will work, but why?

Ctrl + F11 changes orientation. You should read more on Activity lifecycle http://developer.android.com/guide/topics/fundamentals/activities.html#Lifecycle to understand it well. Basically, orientation change causes that your activity is destroyed and recreated. OnCreate method is called again but it will not restore your table created in onActivityResult.

You could also disable orientation changes, see How do I disable orientation change on Android?

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