php - 将数据从 php 文件获取到 Android 应用程序

标签 php android

我是使用 Android 应用程序的新手。我想从 php 文件获取数据到 android,但我不知道该怎么做。

我将使用一个简单的 php 代码示例,我想将其引入 android:

$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。 HERE是 PHP JSON 文档,并且 HERE是从 Android 到任何 JSON url(可能是您的 URL)的连接示例。

关于php - 将数据从 php 文件获取到 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7434900/

相关文章:

PHP 正则表达式错误。编译失败

php - Android - 通过 PHP 脚本上传图片

php - MySql 查询在 php 中不起作用

java - 在开始 Activity 之前需要单击“下一步”按钮两次

android - 将解析库导入到 Android Studio,gradle 错误?

android - 在 map 框中进行离线导航

javascript - 你能帮我使用 php preg_replace 重写我的 javascript 正则表达式吗?

Android:是否有一种编程方式可以在主屏幕上创建网络快捷方式

android - AppCompat v22 : Reference new interpolators via XML

php - 通过电子邮件发送动态生成的调查页面的内容