Retrofit接口的使用

Retrofit接口的使用

案例

// http://api.tianapi.com/nba/?key=71e58b5b2f930eaf1f937407acde08fe&num=10

在constand中拆分前面的地址

//地址
public final static String URL_PATH="http://api.tianapi.com/";


在接口中使用GET方式

像这种带 ?的接口拆分的时候一定要连上?    

@Query ("key") 就是代表了上面的地址中key=后面的数
@Query ("num") 代表了上面地址中num=10

@GET("nba/?")
Call<ResultDatas> getdatas02(@Query ("key") String key,@Query ("num") int num);


调用

先定义

private String key ="71e58b5b2f930eaf1f937407acde08fe";
private int num =10;


serverInterface.getdatas02 (key,num).enqueue (new Callback<ResultDatas> () {}



相关文章:

  • 2021-08-22
  • 2021-06-23
  • 2022-12-23
  • 2021-05-17
  • 2021-11-05
  • 2021-08-05
猜你喜欢
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2021-08-07
  • 2021-08-21
  • 2021-07-14
  • 2021-12-02
相关资源
相似解决方案