在ListView中显示从.php脚本接收的数据

在ListView中显示从.php脚本接收的数据,php,android,json,http,android-listview,Php,Android,Json,Http,Android Listview,如何使用Android代码将数据库表中的数据放入listView 这是PHP代码,我需要Android代码: $your_querry="select * from member "; $query=mysql_query($your_querry); $list=array(); while($row=mysql_fetch_assoc($query)) { $list[]=$row; } echo json_encode($list); 试试这样的 DefaultHttpClie

如何使用Android代码将数据库表中的数据放入
listView

这是PHP代码,我需要Android代码:

$your_querry="select * from member ";
$query=mysql_query($your_querry);
$list=array();
while($row=mysql_fetch_assoc($query))
{
    $list[]=$row;
}

echo json_encode($list);

试试这样的

DefaultHttpClient   httpclient = new DefaultHttpClient(new BasicHttpParams());
HttpGet httppost = new HttpGet("path/to/your/php-script");

httpGet.setHeader("Content-type", "application/json");

InputStream inputStream = null;
String result = null;
try {
    HttpResponse response = httpclient.execute(httppost);           
    HttpEntity entity = response.getEntity();

    inputStream = entity.getContent();

    // Now parse the JSON with some JSON library like Jackson, Gson or JSON.org
    ...
    // Then fill the listView with the objects you parsed
    ...

试试这样的

DefaultHttpClient   httpclient = new DefaultHttpClient(new BasicHttpParams());
HttpGet httppost = new HttpGet("path/to/your/php-script");

httpGet.setHeader("Content-type", "application/json");

InputStream inputStream = null;
String result = null;
try {
    HttpResponse response = httpclient.execute(httppost);           
    HttpEntity entity = response.getEntity();

    inputStream = entity.getContent();

    // Now parse the JSON with some JSON library like Jackson, Gson or JSON.org
    ...
    // Then fill the listView with the objects you parsed
    ...

对于这个问题,请使用JSONParser.java和ListAdapter.java

如果您的listview包含图像,我强烈建议您使用

1-MemoryCache.java.
2-FileCache.java.
3-ImageLoader.java.
4-Utils.java.

这就是我所想的

对于这个问题,请使用JSONParser.java和ListAdapter.java

如果您的listview包含图像,我强烈建议您使用

1-MemoryCache.java.
2-FileCache.java.
3-ImageLoader.java.
4-Utils.java.

这就是我所想的

嗯,在这个过程中有很多步骤。您需要(1)使用异步任务从服务器下载该信息(2)处理您获得的JSON(3)创建一个列表适配器,您可以将这些信息加载到其中-有很多关于如何在google上设置列表视图的教程,您可以找到,但是有太多的步骤来真正给出一个好的答案,这里有很多步骤。您需要(1)使用AsyncTask从服务器下载该信息(2)处理您获得的JSON(3)创建一个列表适配器,将该信息加载到其中-有很多关于如何在google上设置列表视图的教程,您可以找到,但这里的步骤太多,无法给出一个好的答案