我正在使用chatview从异步请求中获取一些数据并使用listview将其显示给用户,但是我无法想出让我的线程结束的方法。
例如,我的test()函数在“try”结束之前被调用
ApiRestClient.get("chatroom/mines", requestparams, new TextHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, org.apache.http.Header[] headers, java.lang.String responseString) {
try {
JSONArray reader = new JSONArray(responseString);
ChatRoomBDD.open();
for (int i = 0; i < reader.length(); i++) {
JSONObject jsonobject = reader.getJSONObject(i);
String idroom = jsonobject.getString("id");
String match_id = jsonobject.getString("url");
newsData = new UserInfoChatRoom();
newsData.setMatch_id(match_id);
newsData.setIdRoom(idroom);
ChatRoomBDD.insertRoom(newsData);
}
} catch (JSONException e) {
}
}
@Override
public void onFailure(int statusCode, org.apache.http.Header[] headers, java.lang.String responseString, java.lang.Throwable throwable) {
d("error", responseString + statusCode);
}
});
test();
}
public void test()
{
//some code
}