package com.example.jdmallbyrv;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;

public class MyRechclerAdapter extends RecyclerView.Adapter<MyViewHolder> {
    private List<JDMechandises> pdata=new ArrayList<JDMechandises>();
    private Context context;

    public MyRechclerAdapter(List<JDMechandises> pdata,Context context){
        this.pdata=pdata;
        this.context=context;
    }
    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.mechandiseitem,parent,false);
        MyViewHolder myViewHolder=new MyViewHolder(view);
        return myViewHolder;
    }
    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder,int i) {
        JDMechandises person=pdata.get(i);
        holder.myimg.setImageResource(person.getImg());
        holder.mytitle.setText(person.getTitle());
        holder.mynumber.setText(person.getTelnumber());
    }



    @Override
    public int getItemCount() {
        return pdata.size();
    }
}




class MyViewHolder extends RecyclerView.ViewHolder{
    ImageView myimg;
    TextView mytitle;
    TextView mynumber;
    public MyViewHolder(View itemview){
        super(itemview);
        myimg=itemview.findViewById(R.id.peos_img);
        mytitle=itemview.findViewById(R.id.peos_name);
        mynumber=itemview.findViewById(R.id.peos_number);
    }


}

