我得到這個錯誤:「偏偏你的應用程序必須停止」偏偏你的應用程序必須關閉
和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
我不entend ListActivity!
我只有:
3 java的文件:
"public class MainActivity extends PreferenceActivity implements OnClickListener"
"public class QuickPrefsActivity extends PreferenceActivity"
"public class ShowSettingsActivity extends Activity"
,所以我不undertand問題出在哪裏從何而來?
如果您正在擴展列表活動,您的列表視圖ID必須是android.R.id.list –
在此處發佈您的代碼 – MAC
這將是很好的檢查偏好活動教程http://androidresearch.wordpress.com/2012/ 03/09 /創建一個首選項活動在Android/ – rajpara