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());
}
答案 0 :(得分:0)
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();