如何使用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);
答案 0 :(得分:3)
对于这个问题,请使用JSONParser.java和ListAdapter.java,
如果您的列表视图包含图片我强烈建议您使用
1-MemoryCache.java.
2-FileCache.java.
3-ImageLoader.java.
4-Utils.java.
我想的全部
答案 1 :(得分:1)
尝试这样的事情
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
...