从async onComplete返回值

时间:2015-07-10 16:48:45

标签: java android vk

gettedID是一个公共变量,在onComplete完成后获取一个值。如何在填充后执行某些代码而不使用单独的线程,我如何监听gettedID值?

VKRequest request = VKApi.wall().get(VKParameters.from("domain", "bitcoin", VKApiConst.OFFSET, offset, VKApiConst.COUNT, count));
request.executeWithListener(new VKRequest.VKRequestListener() {
    @Override
    public void onError(VKError error) {
        System.out.println("error:  " + error);
    }

    @Override
    public void onComplete(VKResponse response) {
        super.onComplete(response);
        try {
            json = response.json.getJSONObject("response").getJSONArray("items");
            for (int i = 0; i < json.length(); i++) {
                returnArray.put(json.getJSONObject(i).get("id").toString());
            }
            gettedID = returnArray;
            //Log.d("BTCR", "gettedID: " + returnArray.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
});

0 个答案:

没有答案