sensorLandscape引发了一个Resources $ NotFoundException

时间:2013-03-05 14:27:35

标签: android android-sensors

我正在尝试为不同的API级别设置正确的横向模式,我遇到了一个问题:

我已将清单文件中的活动方向设置为Landscape,并在活动代码中评估API级别是否更高,如果它大于API 8则将其设置为sensorLandscape,如下所示:

public static final int ANDROID_BUILD_GINGERBREAD = 9;
public static final int SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= ANDROID_BUILD_GINGERBREAD) {
        setRequestedOrientation(SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    }
    setContentView(R.layout.results);
}

它在ICS,JB和GB上运行良好,但在使用Honeycomb平板电脑时,它在纵向模式下会在setContentView时崩溃。在景观上很好......:S

布局文件是:

layout:
    main.xml
layout-land:
    main.xml
    results.xml

我不明白为什么如果API级别应支持sensorLandscape.

,我们不会使用HC平板电脑

谢谢你的时间!

0 个答案:

没有答案
相关问题