嵌套的小Adapter

package com.bawai.dianshang.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bawai.dianshang.R;
import com.bawai.dianshang.bean.ShouBean;
import com.bawai.dianshang.map.model.DengModel;
import com.bumptech.glide.Glide;

import java.util.List;

public class RxxpAdapter extends RecyclerView.Adapter {
Context context;
Listlist;

public RxxpAdapter(Context context, List list) {
    this.context = context;
    this.list = list;
}

@NonNull
@Override
public RxxpAdapter.MyHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    View view= View.inflate(viewGroup.getContext(), R.layout.rxxp_item,null);
    return new MyHolder(view);
}

@Override
public void onBindViewHolder(@NonNull RxxpAdapter.MyHolder myHolder, final int i) {
        myHolder.text.setText(list.get(i).getCommodityName());
        myHolder.text2.setText(list.get(i).getPrice());
    Glide.with(context).load(list.get(i).getMasterPic()).into(myHolder.image);
    myHolder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            bbCallback.ondate(v.getId(),list.get(i).getCommodityName());

        }
    });
}

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

public class MyHolder extends RecyclerView.ViewHolder {

    private final ImageView image;
    private final TextView text;
    private final TextView text2;

    public MyHolder(@NonNull View itemView) {
        super(itemView);
        image = itemView.findViewById(R.id.image_rxxp);
        text = itemView.findViewById(R.id.text_rxxp);
        text2 = itemView.findViewById(R.id.text2_rxxp);
    }
}

BBCallback bbCallback;
public  void setDatas(BBCallback datas){
    this.bbCallback=datas;
}


interface BBCallback{
    void ondate(int id,Object data);
}

}

你可能感兴趣的:(嵌套的小Adapter)