0

我跟着下面的文章

http://blog.sptechnolab.com/2011/02/10/android/android-connecting-to-mysql-using-php/

我能够执行我的 php 文件。我单独执行它并且工作正常。问题出在android执行部分。我正在为我面临的错误发布 Log Cat。尝试放入 ID 为“list”的列表视图,但错误仍然为 1

0-28 16:08:27.201: E/AndroidRuntime(664): **FATAL EXCEPTION: main**
10-28 16:08:27.201: E/AndroidRuntime(664): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.city/com.example.city.City}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.os.Looper.loop(Looper.java:137)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.ActivityThread.main(ActivityThread.java:4424)
10-28 16:08:27.201: E/AndroidRuntime(664):  at java.lang.reflect.Method.invokeNative(Native Method)
10-28 16:08:27.201: E/AndroidRuntime(664):  at java.lang.reflect.Method.invoke(Method.java:511)
10-28 16:08:27.201: E/AndroidRuntime(664):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-28 16:08:27.201: E/AndroidRuntime(664):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-28 16:08:27.201: E/AndroidRuntime(664):  at dalvik.system.NativeStart.main(Native Method)
10-28 16:08:27.201: E/AndroidRuntime(664): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.ListActivity.onContentChanged(ListActivity.java:243)
10-28 16:08:27.201: E/AndroidRuntime(664):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:254)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.Activity.setContentView(Activity.java:1835)
10-28 16:08:27.201: E/AndroidRuntime(664):  at com.example.city.City.onCreate(City.java:35)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.Activity.performCreate(Activity.java:4465)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-28 16:08:27.201: E/AndroidRuntime(664):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-28 16:08:27.201: E/AndroidRuntime(664):  ... 11 more
4

1 回答 1

0

在您的 XML 中更改以下内容:

<Listview
    android:id="@+id/list"
    ...

至:

<ListView
    android:id="@android:id/list"
    ...
于 2012-10-30T00:18:33.003 回答