[英]android parsing json object to listview
最后我放弃了,我需要你的帮助,我有一个简单的问题,
我从此链接获得了一个很棒的教程: http : //wptrafficanalyzer.in/blog/android-json-parsing-with-jsonobject-and-loading-to-listview-example/
在该教程中,使用对象的json数组是这样的:
"{ " +
" \"countries\":[ " +
"{" +
"\"countryname\": \"India\","+
"\"flag\": "+ R.drawable.india + ","+
"\"language\": \"Hindi\","+
"\"capital\": \"New Delhi\"," +
"\"currency\": {" +
"\"code\": \"INR\", " +
"\"currencyname\": \"Rupee\" " +
"}" +
"}, " +
"{" +
"\"countryname\": \"Pakistan\","+
"\"flag\": "+ R.drawable.pakistan + ","+
"\"language\": \"Urdu\","+
"\"capital\": \"Islamabad\"," +
"\"currency\": {" +
"\"code\": \"PKR\", " +
"\"currencyname\": \"Pakistani Rupee\" " +
"}" +
"}," +
"{" +
"\"countryname\": \"Sri Lanka\","+
"\"flag\": "+ R.drawable.srilanka + ","+
"\"language\": \"Sinhala\","+
"\"capital\": \"Sri Jayawardenapura Kotte\"," +
"\"currency\": {" +
"\"code\": \"SKR\", " +
"\"currencyname\": \"Sri Lankan Rupee\" " +
"}" +
"}" +
"]" +
"} "
不,我的问题是,我只需要解析这个简单的json
"{ " +
" \"countries\": " +
"{" +
"\"countryname\": \"India\","+
"\"flag\": "+ R.drawable.india + ","+
"\"language\": \"Hindi\","+
"\"capital\": \"New Delhi\"," +
"\"currency\": {" +
"\"code\": \"INR\", " +
"\"currencyname\": \"Rupee\" " +
"}" +
"} "
那只是jsonobject,我必须在哪里更改代码?
您在此ListViewLoaderTask中进行了更改。.也许在返回适配器时出错,因为它不包含任何列表。
{
"id": 912345678902,
"text": "@android_newb just use android.util.JsonReader!",
"geo": [
50.454722,
-104.606667
],
"user": {
"name": "jesse",
"followers_count": 2
}
}
[{
"id": 912345678902,
"text": "@android_newb just use android.util.JsonReader!",
"geo": [
50.454722,
-104.606667
],
"user": {
"name": "jesse",
"followers_count": 2
}
}]
String strJson =
"{ " +
" \"countries\":[ " +
"{" +
"\"countryname\": \"India\","+
"\"flag\": "+ R.drawable.india + ","+
"\"language\": \"Hindi\","+
"\"capital\": \"New Delhi\"," +
"\"currency\": {" +
"\"code\": \"INR\", " +
"\"currencyname\": \"Rupee\" " +
"}" +
"}, " +
"]" +
"} ";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.