如何放置参数以获取请求?

时间:2019-01-21 01:33:50

标签: java php android-studio get retrofit2

它尝试显示通过GET命令分配给用户的注释列表。从PHP的角度来看,一切正常,但我不知道如何在android studio中对其进行编程?如何将参数放入GET请求?

 @GET("allnotesuser/{user}")
    Call<NotesUserResponse> getAllNotesUser(
            @Path("user") int user
    );

UsersFragment

  @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为null”

recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

0 个答案:

没有答案