I can not VKApiPoll.Answer answer the VKApiPoll.Answer answer - all the time is null .

  VKAttachments att = new VKAttachments(); att = post.attachments; for (VKAttachments.VKApiAttachment attachment : att) { Log.d("TAG", "attachment getType " + attachment.getType()); if (attachment == null) { return; } if (attachment instanceof VKApiPoll) { final VKApiPoll poll = (VKApiPoll) attachment; VKList<VKApiPoll.Answer> answers = poll.answers; Log.d("TAG", "pool question: " + poll.question); holder.layone2.setVisibility(View.VISIBLE); holder.pps1.setText(poll.question); for (VKApiPoll.Answer answer : answers){ holder.pps2.setText(answer.text.trim()); } final String answers_anonymous_textStr = "Всего проголосовало: " + poll.votes + " человек."; holder.pps3.setText(answers_anonymous_textStr); }else{ holder.layone2.setVisibility(View.GONE); holder.pps1.setText(null); holder.pps2.setText(null); holder.pps3.setText(null); } ================ VKRequest reqWall = VKApi.wall().get(VKParameters.from(VKApiConst.OWNER_ID, группа, VKApiConst.EXTENDED, 1, VKApiConst.COUNT, 100, "text")); reqWall.setPreferredLang("ru"); reqWall.executeWithListener(new VKRequest.VKRequestListener() { @Override public void onComplete(VKResponse response) { super.onComplete(response); JSONObject jsonObject = response.json; String owner = null; try { owner = (((JSONObject) ((JSONArray) ((JSONObject) jsonObject.get("response")).get("items")).get(0)).getString("owner_id")); } catch (JSONException e) { e.printStackTrace(); } posts = new VKPostArray(); try { posts.parse(response.json); } catch (JSONException e) { e.printStackTrace(); } try { JSONArray array = ((JSONArray) ((JSONObject) jsonObject.get("response")).get("groups")); } catch (JSONException e) { e.printStackTrace(); } 

enter image description here

  • Oh VKApiPoll.Answer answer = null ... mistaken - sviter-pro
  • The output of answers is the same: answer.text ??? - sviter-pro
  • one
    interesting. here you have the line answers = new VKList<>(); where the empty collection is initialized and then you try to run through it. What else did you expect as a result of such an action? - Alexey Shimansky
  • How to fill it? Even I am stupid - sviter-pro

1 answer 1

I certainly don’t know what is happening here in general, but generally in the line

 answers = new VKList<>(); 

an empty collection is initialized and then you try to run through it. Therefore, null

And you probably need to put the data

 answers = poll.answers; 

Well or what field there should lie in poll look.

  • It did not help ... everything is exactly in the debager size = 0; - sviter-pro
  • @ sviter-pro in poll you what? Does anything come at all? maybe nothing comes at all? The same attachment you bring to VKApiPoll and there may be nothing. See what's in it - Alexey Shimansky
  • Everything works and everything comes except answers !!! Article updated - sviter-pro
  • @ sviter-pro can show what comes in attachment ? - Alexey Shimansky
  • updated article. - sviter-pro