简体   繁体   中英

Android : Connecting to MySQL using PHP

I followed the following article

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

I am able to execute my php file. I executed it individually and its working fine. The problem is in the android execution part. Am posting the Log Cat for the error am facing. Tried putting in a List View with id "list" but the error stil 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

Change the following in your XML:

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

To:

<ListView
    android:id="@android:id/list"
    ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM