我是使用android应用程序的新手。我想从一个PHP文件到Android的数据,我不知道该怎么做。将数据从php文件传输到Android应用程序
我将使用的PHP代码一个简单的例子,我想进入安卓
$array = array(0 => 'zero', 1 => 'one', 2 => 'two');
print $array;
这个脚本是在这里:http://johnyho.net/index.php
能否请您给我一个建议如何得到这个字段放入android中。 非常感谢。
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
AndroidManifext.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.android.websevice.client.samples"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AndroidClientService"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
喜,最好是使用JSON,然后你可以通过分析执行PHP文件的结果得到的那场, – Houcine
谢谢......它不工作......我不知道在xml文件中是否有什么不好的东西......现在也在这里。 –
在我现在的php文件中:$ my_array = array(0 =>'zero',1 =>'one',2 =>'two'); $ json_string = json_encode($ my_array); print $ json_string; .................所以我得到输出[“zero”,“one”,“two”] –