Handling Screen orientation in android -


this app requires both portrait , landscape orientations. here creating "layout-land" folder in resource folder landscape orientation.while doing orientation activity taking xml "layout-land" activity restarting.

so avoid restarting,in manifest using following permissions:

<android:configchanges="keyboardhidden|orientation|screensize"> 

while using above permissions activity not restarting unable take xml "layout-land" folder.

here need:
1. avoid restarting activity
2. making activity take xml "layout-land" folder. new android.please me in this.thanks in advance.

that's way android works. need choose 1 of 3 options:

  1. use exact same layout portait , landscape; then, can use configchanges above. can work if have few minor changes, if can keep majority of layout same , make few items visible/invisible based on orientation.

  2. use different layouts; then, can keep configchanges, have implement loading of new layout in onconfigurationchanged, including taking values old views , adding them new (anything set @ run time: text values, user entered edit texts, check box states, etc).

  3. remove configchange line manifest, , implement onsaveinstancestate , onrestoreinstancestate. these 2 give chance save values want , restore them around restart of activity. same two, don't have manually reset view.

i highly suggest 1 if @ possible. if must use landscape specific layout, going route 3 easiest. i'm big fan of setting configchanges, doesn't work if need different landscape layout.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -

java Extracting Zip file -