Uygulamam onSuccess yöntemimi çalıştırıyor gibi görünmüyor.AsyncHttpClient JSON onSuccess işlevi yürütülüyor
O günlüğüne şöyle diyor: "W/JsonHttpRH: onSuccess (int, Üstbilgi [], JSONArray) yeri etkilenmez, ancak geri arama alındığı"
Birçok insan yerine JSONObject nesnesi arasında JSONArray kullanın, ancak bu benimle durum böyle değil. Kod:
private void fetchDictionary() {
client = new DictionaryClient();
client.getWords("awesome", new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
try {
JSONArray docs = null;
if(response != null) {
// Get the docs json array
docs = response.getJSONArray("docs");
// Parse json array into array of model objects
final ArrayList<Word> words = Word.fromJson(docs);
// Remove all words from the adapter
wordAdapter.clear();
// Load model objects into the adapter
for (Word word : words) {
wordAdapter.add(word); // add word through the adapter
}
wordAdapter.notifyDataSetChanged();
}
} catch (JSONException e) {
// Invalid JSON format, show appropriate error.
e.printStackTrace();
}
}
});
}
Bir API olarak http://dictionaryapi.net/ kullanıyorum. URL'miz şöyle görünür: "http://dictionaryapi.net/api/definition/awesome", bir JSON nesnesini döndürür. bir JSON nesnesi döndüren "http://dictionaryapi.net/api/definition/awesome" :