0

请帮助我的应用程序崩溃这是我的 logcat

    at java.lang.reflect.Method.invoke(Method.java:372) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
06-18 05:03:10.800 10304-10304/com.example.vikram.musicplayer I/Process: Sending signal. PID: 10304 SIG: 9
06-18 05:03:21.908 11965-11965/com.example.vikram.musicplayer V/Monotype: SetAppTypeFace- try to flip, app = com.example.vikram.musicplayer
06-18 05:03:21.916 11965-11965/com.example.vikram.musicplayer V/Monotype:     Typeface getFontPathFlipFont - systemFont = default#default
06-18 05:03:21.919 11965-11965/com.example.vikram.musicplayer V/Monotype: SetAppTypeFace- try to flip, app = com.example.vikram.musicplayer
06-18 05:03:21.919 11965-11965/com.example.vikram.musicplayer V/Monotype:     Typeface getFontPathFlipFont - systemFont = default#default
06-18 05:03:21.948 11965-11965/com.example.vikram.musicplayer V/Monotype: SetAppTypeFace- try to flip, app = com.example.vikram.musicplayer
06-18 05:03:21.949 11965-11965/com.example.vikram.musicplayer V/Monotype:     Typeface getFontPathFlipFont - systemFont = default#default
06-18 05:03:21.960 11965-11979/com.example.vikram.musicplayer I/art: Ignoring second debugger -- accepting and dropping
06-18 05:03:21.963 11965-11965/com.example.vikram.musicplayer D/AndroidRuntime: Shutting down VM
06-18 05:03:21.964 11965-11965/com.example.vikram.musicplayer E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.example.vikram.musicplayer, PID: 11965
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vikram.musicplayer/com.example.vikram.musicplayer.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2320)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2380)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5289)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
         Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
            at android.app.ListActivity.onContentChanged(ListActivity.java:243)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:381)
            at android.app.Activity.setContentView(Activity.java:2195)
            at com.example.vikram.musicplayer.MainActivity.onCreate(MainActivity.java:40)
            at android.app.Activity.performCreate(Activity.java:6018)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2273)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2380) 
            at android.app.ActivityThread.access$800(ActivityThread.java:151) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:135) 
            at android.app.ActivityThread.main(ActivityThread.java:5289) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:372) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
06-18 05:03:24.033 11965-11965/com.example.vikram.musicplayer I/Process: Sending signal. PID: 11965 SIG: 9
4

1 回答 1

0

根据您的 logcat,您需要重新定义您的 ListView id。尝试这个 -

<ListView android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

由于您使用的是 ListActivity,因此您的 xml 文件必须在提及 ID 时指定关键字 android。

希望它会有所帮助:)

于 2016-06-18T07:41:02.053 回答