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. 沒有附加適配器;跳繩佈局:RecyclerView
- 2. E/RecyclerView:沒有附加適配器;跳繩佈局
- 3. 沒有附加適配器;跳繩佈局,但已經設置適配器
- 4. ViewPager:沒有附加適配器;跳繩佈局; AndroidRuntime:java.lang.IllegalStateException:遞歸進入executePendingTransactions
- 5. 無法解決E/RecyclerView:沒有附加適配器;跳過佈局錯誤
- 6. E/RecyclerView:沒有附加適配器;跳過佈局Android RecycleView
- 7. 沒有附加適配器;從RecycleView跳過佈局
- 8. RecyclerView:沒有附加適配器;跳過佈局 - 但適配器已設置
- 9. 沒有附加適配器;跳過片段中的佈局錯誤
- 10. Firebase:RecyclerView:無連接適配器;跳繩佈局
- 11. RecyclerView:沒有附加適配器;跳過佈局 - 回收查看錯誤
- 12. RecyclerView沒有附加適配器;跳過佈局,數據不顯示
- 13. 自定義適配器有此錯誤RecyclerView沒有附加適配器;跳過佈局
- 14. Recycler視圖不顯示。它顯示錯誤爲E/RecyclerView:沒有附加適配器;跳過佈局
- 15. 附帶parce.com.no適配器的Android應用程序;跳過佈局
- 16. RecyclerView沒有附加任何適配器
- 17. RecycleView沒有附加任何適配器
- 18. 沒有適配器連接;跳過佈局錯誤
- 19. 沒有連接適配器;跳過佈局recyclerview錯誤
- 20. 沒有連接適配器;跳過佈局recyclerview
- 21. /RecyclerView:沒有附加適配器;跳過佈局,但只有一行顯示在模擬器
- 22. RecyclerView:沒有附加適配器;跳過layou,翻新
- 23. 如何解決下面的代碼java.lang.StackOverflowError?
- 24. 如何解決下面的htaccess代碼
- 25. 將圖像加載到RecyclerView中會導致「沒有附加適配器;跳過佈局」錯誤
- 26. 下面的控制器代碼有什麼問題?你將如何解決它?
- 27. RecyclerView:沒有附加適配器
- 28. 跳過我的代碼,我該如何解決這個問題?
- 29. ReyclerView。警察數據Json - 沒有適配器連接,跳過佈局
- 30. Symfony:我如何在沒有佈局的頁面中加載.css?
哪裏是你的recycleview代碼? ? – tahsinRupam
這是onCreate() – kirans
@ tahsinRupam,你可以發佈你的recycleview代碼嗎? – shahid17june