我正在创建一个仅在横向模式下针对平板电脑用户的应用程序。所以我创建了一个res
名为 as的文件夹,layout-xlarge-land
并将所有layout xml
文件放入其中并保持为layout folder
空。我还在清单文件中设置了支持屏幕属性
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:normalScreens="false"
android:smallScreens="false" />
我还将所有活动的方向设置为横向
activity
android:name=".HomeActivity"
android:label="@string/title_activity_main"
android:screenOrientation="landscape">
</activity>
当我启动我的应用程序时,它不会开始显示意外停止的消息。
但是当我将所有layout xml
文件放入layout folder
我的应用程序时运行良好。
为什么会有这种行为?在我看来Android system
,应该首先查看 layout-xlarge-land
文件夹以获取 UI。如果找不到,请查看“布局文件夹”。有人可以解释我是对还是错?
日志猫:
08-29 12:06:15.040: E/AndroidRuntime(3468): java.lang.RuntimeException: Unable to
start activity ComponentInfo{com.abs.qpr/com.abs.qpr.LauncherActivity}:
android.content.res.Resources$NotFoundException: Resource ID #0x7f030001
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1751)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.app.ActivityThread.access$1500(ActivityThread.java:122)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.os.Looper.loop(Looper.java:132)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.app.ActivityThread.main(ActivityThread.java:4028)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
java.lang.reflect.Method.invokeNative(Native Method)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
java.lang.reflect.Method.invoke(Method.java:491)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
dalvik.system.NativeStart.main(Native Method)
08-29 12:06:15.040: E/AndroidRuntime(3468): Caused by:
android.content.res.Resources$NotFoundException: Resource ID #0x7f030001
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.content.res.Resources.getValue(Resources.java:1014)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.content.res.Resources.loadXmlResourceParser(Resources.java:2039)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.content.res.Resources.getLayout(Resources.java:853)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.view.LayoutInflater.inflate(LayoutInflater.java:389)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.view.LayoutInflater.inflate(LayoutInflater.java:347)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:245)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.app.Activity.setContentView(Activity.java:1780)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
com.abs.qpr.LauncherActivity.onCreate(LauncherActivity.java:17)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
08-29 12:06:15.040: E/AndroidRuntime(3468): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
08-29 12:06:15.040: E/AndroidRuntime(3468): ... 11 more`