Java 如何从改装中的活动发送查询参数

Java 如何从改装中的活动发送查询参数,java,android,android-studio,retrofit,Java,Android,Android Studio,Retrofit,我有以下用于从服务器检索事务列表的服务: @GET("/api/UserPurchaseReports") Call<List<Transactions>>getTransactions( @Query("mounthNumber")int month, @Query("yearNumber")int year ); 但它不起作用 提前谢谢。使用@Query您不能使用基元类型 改变 @GET("/api/UserPurchaseRepor

我有以下用于从服务器检索事务列表的服务:

@GET("/api/UserPurchaseReports")
Call<List<Transactions>>getTransactions(
        @Query("mounthNumber")int month,
        @Query("yearNumber")int year
);
但它不起作用


提前谢谢。

使用
@Query
您不能使用基元类型

改变

@GET("/api/UserPurchaseReports")
Call<List<Transactions>>getTransactions(
        @Query("mounthNumber")int month,
        @Query("yearNumber")int year
);
@GET(“/api/UserPurchaseReports”)
CallgetTransactions(
@查询(“mounthNumber”)整月,
@查询(“数字”)整年
);

@GET(“/api/UserPurchaseReports”)
CallgetTransactions(
@查询(“mounthNumber”)整数月,
@查询(“数字”)整数年
);

我改变了这一点,但如何从片段中检索月份和年份这里是NetworkSDK中的问题etTransactions(Callbackcallback){callcallcall=BaseClient.getService().getTransactions(42016);call.enqueue(callback);},如果我删除42016或只是设置int、int或integer,整数it报告错误,因为它需要一些int值。我希望该值从我在上面发布的片段发送,基本上用户选择年、月和微调器,整数需要发送到networksdk,以便我可以从该日期检索列表。如果将
Integer
设置为参数,您应该不会有任何问题。自动装箱/取消装箱功能负责转换]我需要在该()中插入什么?我有问题,我尝试了int和Integer,每次需要提供参数时都会报告错误。两个数字。是的,我意识到这一点,但我不能把两个数字放在那里,因为我想从另一个片段中检索这些数字,用户将选择这些数字并将其传递给这个请求
    public void showList(){
    NetworkSDK.getInstance().getTransactions(new     
    Callback<List<Transactions>>() {
        @Override
        public void onResponse(Call<List<Transactions>> call, 
        Response<List<Transactions>> response) {
            if(response.isSuccess()){
                Log.d("Data", String.valueOf(response.isSuccess()));
                TransactionsAdapter transactionsAdapter=new   
            TransactionsAdapter((ArrayList<Transactions>)response.body());
                list.setAdapter(transactionsAdapter);


            }
        }
public void getTransactions(Callback<List<Transactions>>callback){
    Call<List<Transactions>>call = 
BaseClient.getService().getTransactions(4,2016);
            call.enqueue(callback);
}
BaseClient.getService().getTransactions(int,int) 
@GET("/api/UserPurchaseReports")
Call<List<Transactions>>getTransactions(
        @Query("mounthNumber")int month,
        @Query("yearNumber")int year
);
@GET("/api/UserPurchaseReports")
Call<List<Transactions>>getTransactions(
        @Query("mounthNumber")Integer month,
        @Query("yearNumber")Integer year
);