开发者

How to retain a alert dialog when android device is rotated

开发者 https://www.devze.com 2023-02-17 15:32 出处:网络
Hi i am quite new to android.In my application I\'m us开发者_StackOverflow社区ing an alert dialog and i want the alert dialog to be retained when the device is rotated from landscape to portrait and v

Hi i am quite new to android.In my application I'm us开发者_StackOverflow社区ing an alert dialog and i want the alert dialog to be retained when the device is rotated from landscape to portrait and vice-versa.I'm using onRetainNonConfigurationInstance() to restore all other information but alert dialog is not getting retained.Any help is appreciated.


The simplest way is to add

android:configChanges="orientation"

to the activity declaration in manifest, like this:

<activity android:name=".MyActivity"
      android:configChanges="orientation|keyboardHidden"
      android:label="@string/app_name">

This is not recommended but works fine. Read Handling the Configuration Change Yourself for more information.

0

精彩评论

暂无评论...
验证码 换一张
取 消