调试:E / RecyclerView:未连接适配器;跳过布局

时间:2019-05-17 18:43:35

标签: android android-fragments android-recyclerview retrofit2 recycler-adapter

为什么数据没有出现在模拟器上的片段中? 我收到错误消息“未连接适配器;正在跳过布局”

onCreateView方法

v = inflater.inflate(R.layout.frag_diagnosawal, container, false);
    myRecyclerv = (RecyclerView) v.findViewById(R.id.diagawal_recycler);
    myRecyclerv.setLayoutManager(new LinearLayoutManager(getActivity()));
    myRecyclerv.setHasFixedSize(true);

    return v;

OnCreate

 fetchData();

fetchData()

Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(ApiDatatanya.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        ApiDatatanya request = retrofit.create(ApiDatatanya.class);
        Call<List<DataDiagnoseawal>> call = request.getDatas();

        call.enqueue(new Callback<List<DataDiagnoseawal>>() {
            @Override
            public void onResponse(Call<List<DataDiagnoseawal>> call, Response<List<DataDiagnoseawal>> response) {
                DataDA = response.body();
                myReAdapt = new RecyclerAdaptDiagnoseawal(getContext(),DataDA);
                myRecyclerv.setAdapter(myReAdapt);
            }

            @Override
            public void onFailure(Call<List<DataDiagnoseawal>> call, Throwable t) {
                Log.d("Eror",t.getMessage());
            }
        });

0 个答案:

没有答案