0

最後に私はあきらめました、そして私はあなたの助けが必要です、私は簡単な問題を抱えています.

私はこのリンクから素晴らしいチュートリアルを持っています: 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のみです。コードをどこで変更する必要がありますか?

4

1 に答える 1

0

この 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\" " +
                        "}" +
                    "}, " +
                "]" +
            "} ";
于 2013-06-03T10:30:04.050 に答える