2017-10-17 62 views
0
public interface iMakeType { 
    @Headers({"Content-Type:application/json"}) 
    @GET("/getmaptable?map_type=Model&brand=(here i need to pass my value dynamically)") 
    MakeResponse getMakeTypeData(@Query("map_type")String map_type); 
} 

如何将我的品牌价值发送到上述呼叫动态如何发送/使用GET调用

getmaptable?map_type =型号&品牌解析我下面的JSON数据在android系统的改造= BMW

回答

0

使用此:

public interface iMakeType { 
    @Headers({"Content-Type:application/json"}) 
    @GET("/getmaptable") 
    MakeResponse getMakeTypeData(@Query("map_type") String map_type, @Query("brand") String brand); 
} 

然后:

yourApi.getMakeTypeData("Model", "BMW").enqueue(...) 
+1

非常感谢你的家伙! –

0

您可以充分利用@QueryMap改造。

-@QueryMap注释愿与键 - 值对类型字符串的地图。每个具有非空值的键将被映射,您可以动态添加所需的查询参数。

public interface iMakeType { 
    @Headers({"Content-Type:application/json"}) 
    @GET("/getmaptable") 
    MakeResponse getMakeTypeData(@QueryMap Map<String, String> map); 
} 

,并实现它就像如下─

private MakeResponse makeType() { 
    Map<String, String> data = new HashMap<>(); 
    data.put("map_type", "Model"); 
    data.put("brand", "BMW"); 


    MakeResponse call = api.getMakeTypeData(data); 
    call.enqueue(…); 

} 

我希望,这将帮助你添加@Query帕拉姆动态!