Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. package com.shinysoftware.hp.androidswiperecycler.Model;
  2.  
  3. public class Item {
  4.  
  5. String thumbnail;
  6. String price;
  7. String name;
  8. String description;
  9. int id;
  10.  
  11. public Item(){
  12.  
  13. }
  14. public String getThumbnail ()
  15. {
  16. return thumbnail;
  17. }
  18.  
  19. public void setThumbnail (String thumbnail)
  20. {
  21. this.thumbnail = thumbnail;
  22. }
  23.  
  24. public String getPrice ()
  25. {
  26. return price;
  27. }
  28.  
  29. public void setPrice (String price)
  30. {
  31. this.price = price;
  32. }
  33.  
  34. public String getName ()
  35. {
  36. return name;
  37. }
  38.  
  39. public void setName (String name)
  40. {
  41. this.name = name;
  42. }
  43.  
  44. public String getDescription ()
  45. {
  46. return description;
  47. }
  48.  
  49. public void setDescription (String description)
  50. {
  51. this.description = description;
  52. }
  53.  
  54. public int getId ()
  55. {
  56. return id;
  57. }
  58.  
  59. public void setId (int id)
  60. {
  61. this.id = id;
  62. }
  63. }
  64.  
  65. public class CardListAdapter extends RecyclerView.Adapter<CardListAdapter.MyViewHolder> {
  66.  
  67. private Context context;
  68. private List<Item> list;
  69.  
  70. public CardListAdapter(Context context,List<Item> list) {
  71. this.context = context;
  72. this.list = list;
  73. }
  74.  
  75. @Override
  76. public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
  77.  
  78. View itemview=LayoutInflater.from(viewGroup.getContext())
  79. .inflate(R.layout.card_list_item,viewGroup,false);
  80. return new MyViewHolder(itemview);
  81. }
  82.  
  83. @Override
  84. public void onBindViewHolder(MyViewHolder holder, final int position) {
  85.  
  86. final Item item=list.get(position);
  87.  
  88. // BELOW IS MY ERROR LINE. I CAN'T GET MY METHOD (getName())
  89.  
  90. holder.name.setText(item.getName());
  91. }
  92. @Override
  93. public int getItemCount() {
  94. return list.size();
  95. }
  96.  
  97. public class MyViewHolder extends RecyclerView.ViewHolder{
  98.  
  99. public TextView name,description,price;
  100.  
  101. public ImageView thumbnail;
  102.  
  103. public RelativeLayout viewBackground,viewForeground;
  104.  
  105. public MyViewHolder(View itemView) {
  106. super(itemView);
  107.  
  108. name=itemView.findViewById(R.id.name);
  109.  
  110. description=itemView.findViewById(R.id.description);
  111.  
  112. price=itemView.findViewById(R.id.price);
  113.  
  114. thumbnail=itemView.findViewById(R.id.thumbnail);
  115.  
  116. viewBackground=itemView.findViewById(R.id.view_background);
  117.  
  118. viewForeground=itemView.findViewById(R.id.view_foreground);
  119. }
  120. }
  121. }
  122.  
  123. public CardListAdapter(Context context,List<Item> list) {
  124. this.context = context;
  125. this.list = list;
  126. }
  127.  
  128. public CardListAdapter(Context context,List<Item> list) {
  129. this.context = context;
  130. this.list = list;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement