Page 400 - MDP2020-1
P. 400

|    인천전자마이스터고등학교  ·············································································································
            394

            @Override
            public  ViewHolder  onCreateViewHolder(ViewGroup  parent,  int  viewType)
            {
            LayoutInflater  inflater  =  LayoutInflater.from(parent.getContext());

            View  v  =  inflater.inflate(R.layout.item_layout,  parent,  false);
            return  new  ViewHolder(v);
            }



            @Override
            public  void  onBindViewHolder(@NonNull  ViewHolder  holder,  int  position)  {
            holder.textView_name.setText(dataset.get(position).name);
            holder.textView_price.setText(dataset.get(position).price);
            }



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

            }




            ProductData
            package  com.example.s_mart;



            public  class  ProductData  {
            String  name;
            String  price;


            public  ProductData(String  name,  String  price)  {

            this.name  =  name;
            this.price  =  price;


            }
            }
   395   396   397   398   399   400   401   402   403   404   405