Java Android:使用动态URL进行改造

Java Android:使用动态URL进行改造,java,android,retrofit,Java,Android,Retrofit,我有一个类似于http://www.myexample.com/rss/choose.php?type=level&id=2我想在我的android应用程序中使用改型。问题在于类型是一个参数,它可以采用不同的值,如级别,等级,等等。 我不能每次类型更改时都进行改装,因为我在TestsInterface中得到一个“此处不允许使用批注”。我一直在寻找这个,并应用到我的应用程序,但它不工作 static final String BASE_URL = "http://www.myexample.com

我有一个类似于
http://www.myexample.com/rss/choose.php?type=level&id=2
我想在我的android应用程序中使用改型。问题在于
类型
是一个参数,它可以采用不同的值,如
级别
等级
,等等。 我不能每次
类型
更改时都进行改装,因为我在TestsInterface中得到一个“此处不允许使用批注”。我一直在寻找这个,并应用到我的应用程序,但它不工作

static final String BASE_URL = "http://www.myexample.com/rss/";

public void start() {
    Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL)
            .addConverterFactory(SimpleXmlConverterFactory.create()).build();

    TestesInterface testesInterface = retrofit.create(TestesInterface.class);

    Call<Channel> call = testesInterface.loadChannel("choose.php?type=level&id=2");
    call.enqueue(this);
}
static final String BASE\u URL=”http://www.myexample.com/rss/";
公开作废开始(){
改装改装=新改装.Builder().baseUrl(基本URL)
.addConverterFactory(SimpleXmlConverterFactory.create()).build();
TestesInterface TestesInterface=改装.create(TestesInterface.class);
Call Call=testesInterface.loadChannel(“choose.php?type=level&id=2”);
call.enqueue(这个);
}
我的界面:

public interface TestesInterface {
    @GET
    Call<Channel> loadChannel(@Url type);
}
公共接口测试接口{
@得到
调用loadChannel(@Url类型);
}

这使得每次我想将类型更改为不同的值时,我都应该更改
testesInterface.loadChannel(“choose.php?type=level&id=2”)
。这不管用。你能帮我吗?

在尝试了不同的方法后,我得到了解决方案。 我必须使用标签
@Query
在接口上键入
id
,并在start()中调用时发送值:

@GET
调用loadChannel(@Query(“type”)字符串类型,
@查询(“id”)字符串值);

尝试不同的方法后,我得到了解决方案。 我必须使用标签
@Query
在接口上键入
id
,并在start()中调用时发送值:

@GET
调用loadChannel(@Query(“type”)字符串类型,
@查询(“id”)字符串值);
@GET
Call<Channel> loadChannel(@Query("type") String type,
                          @Query("id") String value);