Asahi
Asahi

Reputation: 13506

How to respond to orientation change in Dialog

I have my own implementation of Dialog

public class MyDialog extends Dialog

Is it possible to respond to orientation change from within the MyDialog class and change layout used by the dialog if Activity that creates it has the following in the manifest:

android:configChanges="keyboard|keyboardHidden|orientation"

Thanks

Upvotes: 2

Views: 4573

Answers (2)

arcamax
arcamax

Reputation: 600

The android:configChanges="orientation" flag just indicates that the Activity class will perform the orientation adjustments on it's own and that the Activity should not be destroyed/recreated (onCreate will not be called again) when orientation changes. You can find a good explanation on how to handle this @ How to make an application ignore screen orientation change?

Also in my point of view we should try and avoid setting this flag as it's not considered as a best practice. A more appropriate way to handle Activity recreates upon orientation changes is explained in detail @ http://blog.doityourselfandroid.com/2010/11/14/handling-progress-dialogs-and-screen-orientation-changes/ in detail.

Upvotes: 2

icyerasor
icyerasor

Reputation: 5242

The way you have declared it in your manifest, you say you will handle orientation changes yourself. Your activity won't get restartet, but onConfigurationChanged() will be called. You should do the necessary adjustments there.

You probably have to dismiss the dialog and re-show it within onConfigurationChanged().

Upvotes: 0

Related Questions