E / RecyclerView:没有连接适配器;跳过布局如何解决它是我的代码

时间:2017-03-16 11:56:20

标签: android

public void getResponseForAllMilkHistory(Response response)
    {
//        Log.e("Response", "inside getResponseForAllMilkHistory ");

        Log.e("Response", "In response");
        JSONObject jsonobject = null;
        try{
            //ArrayList<MilkDbModel> data=new ArrayList<>();
            if (response.getIs_success()){
                jsonobject = new JSONObject(response.getData());
                Log.e("check", jsonobject.toString());
                MilkDbModel dbData=new MilkDbModel();
                dbData.milk_id=jsonobject.getInt("milk_id");
                dbData.shop_name=jsonobject.getString("shop_name");
                dbData.date=jsonobject.getString("date");
                dbData.shift=jsonobject.getString("shift");
                dbData.cow_milk=jsonobject.getDouble("cow_milk");
                dbData.buffalo_milk=jsonobject.getDouble("buffalo_milk");
                dbData.cow_milk_price=jsonobject.getDouble("cow_milk_price");
              dbData.buffalo_milk_price=jsonobject.getDouble("buffalo_milk_price");

            }else{
                jsonobject = new JSONObject(response.getData());
                    Log.e("error", jsonobject.toString());
            }

1 个答案:

答案 0 :(得分:0)

你的onCreate

中的

  RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); 
recyclerView.setHasFixedSize(true);
 recyclerView .setLayoutManager(new LinearLayoutManager(this));
 YourAdapter_Class adapter= new YourAdapter_Class(arraylist/linklist or whatever parameter is);
recyclerView.setAdapter(adapter);

当您解析数据时,请通知适配器,如此

recyclerView.notifyDataSetChanged();