Fix The requestFeature() Must Be Called Before Adding Content RunTimeException

If you encounter this error message, I figure you used the requestWindowFeature() method in a class that already inherits from Activity. Say, PreferenceActivity perhaps?

While the rule to use this method should be before one sets the content view of the Activity, in the case of a PreferenceActivity class, it is different.

Since super.onCreate() is called, the ViewGroup is set up so you are not allowed to change the Window‘s parameters.

The workaround for this is to call the requestWindowFeature() method first before super.onCreate(). That should fix it.

Related Posts Plugin for WordPress, Blogger...

1 comment

Leave a Reply

Your email address will not be published. Required fields are marked *