私のアプリケーションは私のonSuccessメソッドを実行できないようです。AsyncHttpClient JSON onSuccess関数が実行されていません
これは、ログに言う: "W/JsonHttpRH:するonSuccess(int型、ヘッダー[]、JSONArray)オーバーライドされなかったが、コールバックを受信しました"
は、多くの人が代わりにJSONObjectのJSONArrayを使用していますが、これは、私には当てはまりません。コードは次のとおりです。
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();
}
}
});
}
私はAPIとしてhttp://dictionaryapi.net/を使用しています。私のURLは次のようになります: "http://dictionaryapi.net/api/definition/awesome"これはJSONオブジェクトを返します。