开发者

How to retain a alert dialog when android device is rotated

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜