我怎样才能设置定向修复的所有活动 [英] How can I set Orientation Fixed for all activities

查看:152
本文介绍了我怎样才能设置定向修复的所有活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android的布局。我如何设定方向固定在AndroidMainfest.xml应用标签的所有活动? 我不想单独设置方向的每一项活动。 先谢谢了。

Android Layout. How can I set Orientation Fixed for all activities in application Tag of AndroidMainfest.xml ? I don't want to set orientation for each activity individually. Thanks in advance.

推荐答案

GoogleIO 的应用程序有一个ActivityHelper类。它有一个静态方法叫初始化()它处理很多事情发生的每个活动。然后,它仅仅是1号线的code。在的onCreate()方法,你需要记住,可以处理设置这个值和其他几个人所必需的各活动。

The GoogleIO app has a ActivityHelper class. It has a static method called initialize() which handles a lot things that happen for every Activity. Then it is just 1 line of code in the onCreate() method that you need to remember, that could handle setting that value and several others that are necessary for each activity.

编辑:否进口或类似的东西。创建一类称为ActivityHelper

No importing or anything like that. Create a class called ActivityHelper

public class ActivityHelper {
    public static void initialize(Activity activity) {
        //Do all sorts of common task for your activities here including:

        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

然后在所有您的活动中的onCreate()方法调用 ActivityHelper.initialize() 如果您正计划开发的表,以及你可能要考虑使用:

Then in all of your activies onCreate() method call ActivityHelper.initialize() If you are planning on developing for tables as well you may want to consider using:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);

我写了更多关于此<一个href="http://stackoverflow.com/questions/6605986/android-natural-sensor-orientation-help">here

编辑:对不起......你需要传递的活动。见code以上

Sorry... you need to pass the the Activity. see the code above

这篇关于我怎样才能设置定向修复的所有活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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