我正在尝试为不同的屏幕尺寸制作布局。在我想要在我的三星 Galaxy Tab 2 7.0 上很好地显示相同的布局之后,我开始为我的智能手机制作一些按钮的基本布局。所以我按照android开发网站上的说明进行操作。
我首先创建了文件夹“layout-large”并创建了第二个布局,但这次是为平板电脑创建的,它不起作用。之后我尝试使用名为“layout-sw600dp”的文件夹并得到相同的结果,它崩溃了。我尝试使用调试模式,但由于某种原因这也不起作用。
LogCat 代码如下,希望有人能提供帮助。亲切的问候
08-29 10:56:56.125: E/AndroidRuntime(6457): FATAL EXCEPTION: main
08-29 10:56:56.125: E/AndroidRuntime(6457): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.quality_of_life/com.example.quality_of_life.MainActivity}: java.lang.NullPointerException
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.os.Handler.dispatchMessage(Handler.java:99)
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.os.Looper.loop(Looper.java:137)
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.app.ActivityThread.main(ActivityThread.java:4895)
08-29 10:56:56.125: E/AndroidRuntime(6457): at java.lang.reflect.Method.invokeNative(Native Method)
08-29 10:56:56.125: E/AndroidRuntime(6457): at java.lang.reflect.Method.invoke(Method.java:511)
08-29 10:56:56.125: E/AndroidRuntime(6457): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
08-29 10:56:56.125: E/AndroidRuntime(6457): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
08-29 10:56:56.125: E/AndroidRuntime(6457): at dalvik.system.NativeStart.main(Native Method)
08-29 10:56:56.125: E/AndroidRuntime(6457): Caused by: java.lang.NullPointerException
08-29 10:56:56.125: E/AndroidRuntime(6457): at com.example.quality_of_life.MainActivity.addListenerOnButton(MainActivity.java:29)
08-29 10:56:56.125: E/AndroidRuntime(6457): at com.example.quality_of_life.MainActivity.onCreate(MainActivity.java:20)
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.app.Activity.performCreate(Activity.java:5163)
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
08-29 10:56:56.125: E/AndroidRuntime(6457): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
08-29 10:56:56.125: E/AndroidRuntime(6457): ... 11 more