Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.shinysoftware.hp.androidswiperecycler.Model;
- public class Item {
- String thumbnail;
- String price;
- String name;
- String description;
- int id;
- public Item(){
- }
- public String getThumbnail ()
- {
- return thumbnail;
- }
- public void setThumbnail (String thumbnail)
- {
- this.thumbnail = thumbnail;
- }
- public String getPrice ()
- {
- return price;
- }
- public void setPrice (String price)
- {
- this.price = price;
- }
- public String getName ()
- {
- return name;
- }
- public void setName (String name)
- {
- this.name = name;
- }
- public String getDescription ()
- {
- return description;
- }
- public void setDescription (String description)
- {
- this.description = description;
- }
- public int getId ()
- {
- return id;
- }
- public void setId (int id)
- {
- this.id = id;
- }
- }
- public class CardListAdapter extends RecyclerView.Adapter<CardListAdapter.MyViewHolder> {
- private Context context;
- private List<Item> list;
- public CardListAdapter(Context context,List<Item> list) {
- this.context = context;
- this.list = list;
- }
- @Override
- public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
- View itemview=LayoutInflater.from(viewGroup.getContext())
- .inflate(R.layout.card_list_item,viewGroup,false);
- return new MyViewHolder(itemview);
- }
- @Override
- public void onBindViewHolder(MyViewHolder holder, final int position) {
- final Item item=list.get(position);
- // BELOW IS MY ERROR LINE. I CAN'T GET MY METHOD (getName())
- holder.name.setText(item.getName());
- }
- @Override
- public int getItemCount() {
- return list.size();
- }
- public class MyViewHolder extends RecyclerView.ViewHolder{
- public TextView name,description,price;
- public ImageView thumbnail;
- public RelativeLayout viewBackground,viewForeground;
- public MyViewHolder(View itemView) {
- super(itemView);
- name=itemView.findViewById(R.id.name);
- description=itemView.findViewById(R.id.description);
- price=itemView.findViewById(R.id.price);
- thumbnail=itemView.findViewById(R.id.thumbnail);
- viewBackground=itemView.findViewById(R.id.view_background);
- viewForeground=itemView.findViewById(R.id.view_foreground);
- }
- }
- }
- public CardListAdapter(Context context,List<Item> list) {
- this.context = context;
- this.list = list;
- }
- public CardListAdapter(Context context,List<Item> list) {
- this.context = context;
- this.list = list;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement