不幸的是你的应用必须关闭

时间:2012-09-04 13:33:18

标签: android

我收到此错误:“不幸的是,您的应用必须停止”

和Logcat,请有人告诉我问题在哪里?

09-04 13:29:56.840: E/AndroidRuntime(574): FATAL EXCEPTION: main
09-04 13:29:56.840: E/AndroidRuntime(574): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fast/com.example.fast.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.os.Looper.loop(Looper.java:137)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.ActivityThread.main(ActivityThread.java:4424)
09-04 13:29:56.840: E/AndroidRuntime(574):  at java.lang.reflect.Method.invokeNative(Native Method)
09-04 13:29:56.840: E/AndroidRuntime(574):  at java.lang.reflect.Method.invoke(Method.java:511)
09-04 13:29:56.840: E/AndroidRuntime(574):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-04 13:29:56.840: E/AndroidRuntime(574):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-04 13:29:56.840: E/AndroidRuntime(574):  at dalvik.system.NativeStart.main(Native Method)
09-04 13:29:56.840: E/AndroidRuntime(574): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.ListActivity.onContentChanged(ListActivity.java:243)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.preference.PreferenceActivity.onContentChanged(PreferenceActivity.java:944)
09-04 13:29:56.840: E/AndroidRuntime(574):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:254)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.Activity.setContentView(Activity.java:1835)
09-04 13:29:56.840: E/AndroidRuntime(574):  at com.example.fast.MainActivity.onCreate(MainActivity.java:50)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.Activity.performCreate(Activity.java:4465)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-04 13:29:56.840: E/AndroidRuntime(574):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
09-04 13:29:56.840: E/AndroidRuntime(574):  ... 11 more

我没有参加ListActivity!

我只有:

3个jave文件:

"public class MainActivity extends PreferenceActivity  implements OnClickListener"

"public class QuickPrefsActivity  extends PreferenceActivity"

"public class ShowSettingsActivity extends Activity"

所以我不承担问题的来源?

1 个答案:

答案 0 :(得分:1)

请参阅

RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

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

如果您仍想使用ListActivity,这将解决错误。