android - Android改造后数据
问题描述
我正在使用带有 Retrofit 的 Android Recyclerview,它在没有任何发布数据的情况下工作。我需要在我当前的代码中发布一些数据。
下面是我当前的 ApiInterface
public interface ApiInterface {
@GET("mypage.php")
Call<Pojo> getData();
}
在我的活动中,我通过以下代码调用它
ApiInterface apiInterface = (ApiInterface) RetrofitClient.getRetrofitInstance().create(ApiInterface.class);
Call<Pojo> listingdata = apiInterface.getData();
listingdata.enqueue(new Callback<Pojo>() {
@Override
public void onResponse(Call<Pojo> call, Response<Pojo> response) {
if(response.isSuccessful()){
recycleradpter recycleradpter = new recycleradpter(response.body().getData());
recyclerView.setAdapter(recycleradpter);
progressbar2.setVisibility(View.GONE);
}
}
@Override
public void onFailure(Call<Pojo> call, Throwable t) {
//System.out.println("12345678934567890234567890");
//Toast.makeText(getActivity(), "No Connected internet", Toast.LENGTH_SHORT).show();
progressbar2.setVisibility(View.GONE);
dialogfunction();
}
});
如何根据上述代码中传递的数据获取数据
解决方案
如果要发送发布请求,则必须创建如下所示的方法。该方法的调用将类似于获取请求。只需传递您的帖子正文的参数。你可以在这里了解详情。
@POST("mypage.php")
Call<Pojo> postData(
@Field("param1") String param1,
@Field("param2") int param2
);
推荐阅读
- contacts - 定义了 VCF TYPE=pref 的标准源(作为媒体的首选)?
- angular - 有没有办法用 devextreme angular 向手风琴添加一个按钮?
- clips - 如何添加全局变量来计算是或否响应的数量?
- c# - 如何在父标签页 xamarin 表单中更新徽章计数器
- c++ - 我应该有什么结构来模拟嵌入式系统类以进行桌面测试?
- arduino - 为什么我的温度探头读数如此之高?
- unity3d - 尝试构建 ios 应用程序时出现统一错误
- java - Redhat Fuse 更新了功能 repo 列表?
- android - Android Q Beta 4 获得 IMEI 和 IMSI
- django - 如何将用户流量的剩余负载从谷歌计算虚拟机分配到谷歌应用引擎?用 apache 运行 django