简体   繁体   English

使用TabActivities忽略screenOrientation

[英]screenOrientation ignored with TabActivities

My main activity is a TabActivity. 我的主要活动是TabActivity。

I have some activities presented by the tab activity which I want to lock to portrait orientation. 我有一些活动由标签活动提供,我想锁定纵向。

In AndroidManifest.xml when I set the screenOrientation property for any of the activities presented in the TabActivity it seems to be ignored for example: 在AndroidManifest.xml中,当我为TabActivity中显示的任何活动设置screenOrientation属性时,它似乎被忽略,例如:

   <activity android:name="FeedActivity"
              android:screenOrientation="portrait">
    </activity>

What is the most effective way of selectively disabling orientation changes with Tab Activities? 使用Tab活动有选择地禁用方向更改的最有效方法是什么? Is it possible via the manifest? 是否有可能通过清单?

This project is currently firmly pre-honeycomb. 该项目目前是坚固的蜂窝状。 While I'm looking forward to being able to update it to API 11 and beyond I'm trying to find out if it is possible to address this problem without moving to fragments. 虽然我期待能够将其更新到API 11及更高版本,但我试图找出是否可以解决此问题而无需转移到片段。

Do not use TabActivity, it's deprecated :) 不要使用TabActivity,它已被弃用:)

Use TabHost with TabWdiget directly, with Activity 使用TabHdiget直接使用TabHost,使用Activity

If you have content or tabs repeated over application you can use Fragments from compatibility package, there are good tutorial by link http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/ 如果你有重复的应用程序内容或标签,你可以使用兼容包中的碎片,有链接http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/的好教程

For my case, I wanted ALL activities presented by the parent TabActivity to be locked in Potrait mode. 对于我的情况,我希望父TabActivity提供的所有活动都以Potrait模式锁定。 Thus I only had to add 因此我只需要添加

android:screenOrientation="portrait"

to my TabActivity. 到我的TabActivity。 I did not need to add it to each individual child tab. 我不需要将它添加到每个单独的子选项卡。

I went for this quick and dirty way because I plan to move the app to use Action Bar in the future. 我采用这种快速而肮脏的方式,因为我打算将应用程序移动到将来使用Action Bar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM