我正在开发应用程序,因为我希望 ListView 在纵向模式下具有图像,而在横向模式下具有相同图像的 GalleryView 我在 res/layout-land/main.xml(Landscape) 和普通 res/layout/main.xml (portrait) 中创建了文件夹但我遇到了一个例外
03-02 11:21:06.420: E/AndroidRuntime(775): FATAL EXCEPTION: main
03-02 11:21:06.420: E/AndroidRuntime(775): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.landscape/com.landscape.ListAvtivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
03-02 11:21:06.420: E/AndroidRuntime(775): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-02 11:21:06.420: E/AndroidRuntime(775): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-02 11:21:06.420: E/AndroidRuntime(775): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-02 11:21:06.420: E/AndroidRuntime(775): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-02 11:21:06.420: E/AndroidRuntime(775): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 11:21:06.420: E/AndroidRuntime(775): at android.os.Looper.loop(Looper.java:130)
03-02 11:21:06.420: E/AndroidRuntime(775): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-02 11:21:06.420: E/AndroidRuntime(775): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 11:21:06.420: E/AndroidRuntime(775): at java.lang.reflect.Method.invoke(Method.java:507)
03-02 11:21:06.420: E/AndroidRuntime(775): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-02 11:21:06.420: E/AndroidRuntime(775): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-02 11:21:06.420: E/AndroidRuntime(775): at dalvik.system.NativeStart.main(Native Method)
03-02 11:21:06.420: E/AndroidRuntime(775): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
03-02 11:21:06.420: E/AndroidRuntime(775): at android.app.ListActivity.onContentChanged(ListActivity.java:243)
03-02 11:21:06.420: E/AndroidRuntime(775): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:210)
03-02 11:21:06.420: E/AndroidRuntime(775): at android.app.Activity.setContentView(Activity.java:1657)
03-02 11:21:06.420: E/AndroidRuntime(775): at com.landscape.ListAvtivity.onCreate(ListAvtivity.java:43)
03-02 11:21:06.420: E/AndroidRuntime(775): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-02 11:21:06.420: E/AndroidRuntime(775): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-02 11:21:06.420: E/AndroidRuntime(775): ... 11 more
当我从布局中删除 main.xml 时,应用程序工作正常并且只显示 ListView。