用Pojo改造arrayadapter

时间:2015-03-21 14:24:58

标签: java android json android-arrayadapter retrofit

我有阵列问题。我必须从Retrofit中回答并在Listview中显示。

服务器给出答案:

{"message":"Welcome in room 3","roomNumber":"3","questions":[{"type":"trueFalse","id":1,"answer":true},{"type":"oneChoice","id":2,"answer":"A"},{"type":"multiChoice","id":3,"answer":"A,B,C"},

我的改造:

@GET("/room/{nr}")
void enterToRoom(@Path("nr") String RoomNr, Callback <Question> cb);

我的第一个Pojo课程:

public class GetQuestionJSON {
private String message;
private String roomNumber;
private List<Question> questions = new ArrayList<Question>();
private Map<String, Object> additionalProperties = new HashMap<String,Object>();

get/set
....
}

我的第二个Pojo课程:

public class Question {
private String type;
private Integer id;
private String answer;
public Map<String, Object> additionalProperties = new HashMap<String,Object>();

get/set
...
}

我的改造回答:

    RestClient.get().enterToRoom(RoomNumber,new Callback<Question>() {
        @Override
        public void success(Question question, Response response) {


        }

        @Override
        public void failure(RetrofitError error) {

        }
    });

在日志中,我看到了Retrofit的答案,但我不知道如何将它用于创建列表视图。

感谢您的帮助!!

0 个答案:

没有答案