android – How to get multiple posts when receiving response from wall.get ()? (VKApi)

Question:

I make a request to the Vk.com API:

VKRequest request = VKApi.wall().get(VKParameters.from(VKApiConst.OWNER_ID,-*моя_группа*,VKApiConst.EXTENDED,1,VKApiConst.COUNT,1,VKApiConst.FIELDS,"text"));
            request.executeWithListener(new VKRequest.VKRequestListener() {
                @Override
                public void onComplete(VKResponse response) {
                    VKList<VKApiPost> posts = (VKList<VKApiPost>) response.parsedModel;
                    VKApiPost post = posts.get(0);
                    Log.d("Post:", post.toString());
                    String textpost = post.text;
                    System.out.println(textpost);

                }

The text of one post from the wall of the specified group is displayed in the console. What needs to be done so that when changing:

VKApiConst.COUNT,1

on:

VKApiConst.COUNT,5

Displayed all 5 posts?

Answer:

Understood. Maybe someone will come in handy. We set, for example, the output of the last two posts from the group:

VKApiConst.COUNT,2

And we will organize their output through a loop:

for (int i=0; i<2; i++) {
                        VKApiPost post = posts.get(i);
                        String textpost = post.text;
                        System.out.println(textpost);
                    }

In the console you will see the text of the last two posts.

Scroll to Top