【发布时间】:2019-07-08 03:34:31
【问题描述】:
我有网址
https://pixabay.com/api/?key=12973823-c1d0c689a2cb0af7706951221&q=dogs&image_type=photo
在上面的 url 中,q=query 这里是我需要更改数据以传递参数的地方。
但我不知道如何仅在 q 中传递参数,而 q 之后的所有其他参数都是固定的。
我只能作为静态应用,但我不知道如何通过将 edittext 字段作为字符串传递给该参数 q= 来更改 q=
public class RetrofitService {
private static Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://pixabay.com/api/")
.addConverterFactory(GsonConverterFactory.create())
.build();
//can't change to private. Since the use case of create service is in another class
public static <S> S createService(Class<S> serviceClass) {
return retrofit.create(serviceClass);
}
}
public interface ImageApiInterface {
@GET("?key=12973823-c1d0c689a2cb0af7706951221&q=dogs&image_type=photo")
Call<MyImages> getMovieDetails();
}
在这里,我将静态字符串作为 dog 传递,它正在工作,但我需要将其更改为输入参数。
【问题讨论】:
标签: android android-recyclerview gson retrofit2