How to get List from JSON list using Retrofit 2?

前端 未结 2 1439
再見小時候
再見小時候 2021-01-26 20:21

I am new to Android. I need to get a list of strings from a JSON list. It will be added to a Spinner list. I have the list on server like

[{\"bgrou         


        
2条回答
  •  面向向阳花
    2021-01-26 20:46

    This is sample code :

     GroupService groupService = createService(GroupService.class);
    
     Call> groupCall = groupService.getGroups();
    
        groupCall.enqueue(new Callback>() {
                @Override
                public void onResponse(retrofit.Response> response, Retrofit retrofit) {
    
    
                }
    
                @Override
                public void onFailure(Throwable t) {
                    t.printStackTrace();
    
                }
            });
    

    Interfaces :

    public interface GroupService {
    
    @GET("")
    Call> getGroups();
    }
    

    Also create model name Groups.

    I hope this helps you.

提交回复
热议问题