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
A
回答
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();
+0
@kirans,让我知道是否有任何问题 – shahid17june
+0
感谢您给予时间 – kirans
+0
@ kirans,请接受答案,如果工作,以便其他人可以使用它。 – shahid17june
-1
try {
ArrayList<MilkDbModel> data = new ArrayList<>();
if (response.getIs_success()) {
jsonobject = new JSONObject(response.getData());
Log.e("check", jsonobject.toString());
for (int i = 0; i < jsonobject.length(); i++) {
MilkDbModel dbData = new MilkDbModel();
dbData.milk_id = jsonobject.getJSONObject(i).getInt("milk_id");
dbData.shop_name = jsonobject.getJSONObject(i).getString("shop_name");
dbData.date = jsonobject.getJSONObject(i).getString("date");
dbData.shift = jsonobject.getJSONObject(i).getString("shift");
dbData.cow_milk = jsonobject.getJSONObject(i).getDouble("cow_milk");
dbData.buffalo_milk = jsonobject.getJSONObject(i).getDouble("buffalo_milk");
dbData.cow_milk_price = jsonobject.getJSONObject(i).getDouble("cow_milk_price");
dbData.buffalo_milk_price = jsonobject.getJSONObject(i).getDouble("buffalo_milk_price");
data.add(dbData)
}
setadapter(data)
} else {
jsonobject = new JSONObject(response.getData());
Log.e("error", jsonobject.toString());
}
} catch(Exception e){
e.printStackTrace();
}
public void setadapter(ArrayList<MilkDbModel> list) {
adapter = new NameOfTheAdapter(getActivity(), list);
LinearLayoutManager layoutManager
= new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
}
相关问题
- 1. E/RecyclerView:没有附加适配器;跳绳布局
- 2. 没有附加适配器;跳绳布局:RecyclerView
- 3. 没有附加适配器;跳绳布局,但已经设置适配器
- 4. ViewPager:没有附加适配器;跳绳布局; AndroidRuntime:java.lang.IllegalStateException:递归进入executePendingTransactions
- 5. 无法解决E/RecyclerView:没有附加适配器;跳过布局错误
- 6. RecyclerView-:没有连接适配器;跳绳布局
- 7. Android RecyclerView:没有附加适配器;跳过布局
- 8. 没有附加适配器;使用RecyclerView时跳过布局
- 9. Android - RecyclerView:没有附加适配器;跳过布局?
- 10. E/RecyclerView:没有附加适配器;跳过布局Android RecycleView
- 11. 没有附加适配器;从RecycleView跳过布局
- 12. RecyclerView:没有附加适配器;跳过布局 - 但适配器已设置
- 13. 没有附加适配器;跳过片段中的布局错误
- 14. Firebase:RecyclerView:无连接适配器;跳绳布局
- 15. RecyclerView:没有附加适配器;跳过布局 - 回收查看错误
- 16. RecyclerView没有附加适配器;跳过布局,数据不显示
- 17. 自定义适配器有此错误RecyclerView没有附加适配器;跳过布局
- 18. 我如何解决下面的代码?
- 19. 2回收站视图适配器,第一个显示图像第二个显示错误没有附加适配器;跳绳布局
- 20. Recycler视图不显示。它显示错误为E/RecyclerView:没有附加适配器;跳过布局
- 21. 附带parce.com.no适配器的Android应用程序;跳过布局
- 22. RecycleView没有附加任何适配器
- 23. RecyclerView没有附加任何适配器
- 24. 没有连接适配器;跳过布局recyclerview错误
- 25. 没有适配器连接;跳过布局错误
- 26. 没有连接适配器;跳过布局recyclerview
- 27. /RecyclerView:没有附加适配器;跳过布局,但只有一行显示在模拟器
- 28. RecyclerView:没有附加适配器;跳过layou,翻新
- 29. RecyclerView:没有附加适配器;跳过活动
- 30. 如何解决下面的代码java.lang.StackOverflowError?
哪里是你的recycleview代码? ? – tahsinRupam
这是onCreate() – kirans
@ tahsinRupam,你可以发布你的recycleview代码吗? – shahid17june