Android的活动,如何覆盖清单的Andr​​oid:configChanges与Java code? [英] Android Activity, how to override manifest's android:configChanges with Java code?

查看:273
本文介绍了Android的活动,如何覆盖清单的Andr​​oid:configChanges与Java code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编码自定义活动类(使用它作为一个超类为我的其他活动课),它的首要许多默认功能。其中一个功能我想是的方向处理,而我能做到这一点,它需要

I'm coding a custom Activity class (using it as a super class for my other Activity classes) where it's overriding many default functionalities. One of these functionalities I want is orientation handling, and while I can do it, it requires

android:configChanges="orientation"

在清单中。有没有办法强制执行同样的事情线之上,但在Java code?

in the manifest. Is there a way to enforce the same thing as the line above, but in java code?

推荐答案

您仍然需要包括在XML中的属性,但你可以处理它在Java中也;在这里看到我的博客文章:http://c0deattack.word$p$pss.com/2010/12/25/dealing-with-screen-orientation-changes-manually/

You'll still need to include the attribute in the XML but you can handle it in Java too; see my blog post here: http://c0deattack.wordpress.com/2010/12/25/dealing-with-screen-orientation-changes-manually/

编辑:您不能设置configChanges属性编程。我想这是跟在创建活动的方式。他们从XML首先创建,然后在活动的执行被覆盖的方法被调用。没有什么的API,可以让你改变configChanges属性,

You cannot set the configChanges attribute programmatically. I guess it's to do with the way an Activity is created. They're created from the XML first and then the overridden methods in your activity implementation are invoked. There's nothing in the API that lets you change the configChanges attribute.

这篇关于Android的活动,如何覆盖清单的Andr​​oid:configChanges与Java code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆