java - 如何输入参数来获取请求?
问题描述
它尝试显示通过 GET 命令分配给用户的笔记列表。从 PHP 方面来看,一切正常,但我不知道如何在 android studio 中对其进行编程?如何将参数放入 GET 请求?
@GET("allnotesuser/{user}")
Call<NotesUserResponse> getAllNotesUser(
@Path("user") int user
);
用户片段
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
User user = SharedPrefManager.getInstance(getActivity()).getUser();
Call<NotesUserResponse> call = RetrofitClient.getInstance().getApi().getAllNotesUser(user.getusers_id());
recyclerView = view.findViewById(R.id.recycler_view_notes_user);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
call.enqueue(new Callback<NotesUserResponse>() {
@Override
public void onResponse(Call<NotesUserResponse> call, Response<NotesUserResponse> response) {
notesUserList= response.body().getAllNotesUser();
adapterNotesUser = new NotesUserAdapter(getActivity(),notesUserList);
recyclerView.setAdapter(adapterNotesUser);
}
@Override
public void onFailure(Call<NotesUserResponse> call, Throwable t) {
}
});
}
在这一行中,我收到错误“revylerview.setLayoutManager 为空”
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
解决方案
推荐阅读
- javascript - React native - Function CollectionReference.doc() 需要它的第一个参数
- fft - 使用 fft 的二阶导数
- android-viewpager - ViewPager2 迁移后出现无效 ID 0x00000001 错误
- go - 如何添加两个curve25519点
- flutter - 如何在电话身份验证期间删除移动设备中的 reCaptcha 屏幕?
- google-apps-script - Gmail 插件 - 将邮件错误地视为 - “不能使用垃圾邮件和可疑邮件”
- java - Spring Cloud 配置服务器启动失败
- python-3.x - 如何将数据框中的列替换为函数的结果
- reactjs - 什么可能导致 React Native 组件不断地卸载和重新安装?
- android - 信号 11 (SIGSEGV),代码 2 (SEGV_ACCERR)