如何修复未连接适配器;跳过Android Pie中的布局

时间:2019-08-18 04:23:54

标签: java android

当我通过排球recyclerview解析数据时,在android pie下工作正常,但是我没有连接适配器;跳过Android Pie版本中的布局。

在onCreateView的片段中

    recyclerView= view.findViewById(R.id.vaccine_recycler);

    recyclerView.setHasFixedSize(true);

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

在凌空jsonobject请求中

FragmentManager fragmentManager=getFragmentManager();
                                    VaccineAdapter adapter= new VaccineAdapter(getActivity(),vaccineInfoList,fragmentManager);
                                    recyclerView.setAdapter(adapter);

下面给出了我的适配器

    public class VaccineAdapter extends RecyclerView.Adapter<VaccineAdapter.ViewHolder> {
        Context context;
        List<VaccineInfo> modelList;
        LayoutInflater layoutInflater;
        FragmentManager fragmentManager;

        public VaccineAdapter(Context context, List<VaccineInfo> modelList, FragmentManager fragmentManager) {
            this.context = context;
            this.modelList = modelList;
            this.fragmentManager = fragmentManager;
            layoutInflater=LayoutInflater.from(context);

        }

        @NonNull
        @Override
        public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
            View view= layoutInflater.inflate(R.layout.vaccine_row,viewGroup,false);
            return new ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(@NonNull final ViewHolder viewHolder, final int i) {

        }





        @Override
        public int getItemCount() {
            return modelList.size();
        }

        public class ViewHolder extends RecyclerView.ViewHolder {
           .......

            }
        }
    }

这是我的错误消息E / RecyclerView:未连接适配器;跳过布局。

0 个答案:

没有答案