recyclerview 单击转到新页面 android 页面 info.xml 并发送产品标题 我正在尝试创建一个电子商务应用程序 如何在 RecyclerView 列表中添加 onclick 打开产品信息页面(如新活动),我还想发送产品标题和产品信息页面中的 ID,
public class adepter extends RecyclerView.Adapter<adepter.viewholder> {
private Context mCtx;
private List<Product> productList;
public adepter(Context mCtx, List<Product> productList) {
this.mCtx = mCtx;
this.productList = productList;
}
@NonNull
@Override
public viewholder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater=LayoutInflater.from(mCtx);
View v =inflater.inflate(R.layout.product_list, parent, false);
return new viewholder(v);
}
@Override
public void onBindViewHolder(@NonNull viewholder holder, int position) {
Product product = productList.get(position);
//loading the image
Glide.with(mCtx)
.load(product.getImage())
.into(holder.imageView);
holder.textViewTitle.setText(product.getTitle());
holder.textViewShortDesc.setText(product.getShortdesc());
holder.textViewtype.setText(String.valueOf(product.getType()));
holder.textViewPrice.setText(String.valueOf(product.getPrice()));
}
@Override
public int getItemCount() {
return productList.size();
}
public class viewholder extends RecyclerView.ViewHolder{
TextView textViewTitle, textViewShortDesc, textViewtype, textViewPrice;
ImageView imageView;
public viewholder(@NonNull View itemView) {
super(itemView);
textViewTitle = itemView.findViewById(R.id.textViewTitle);
textViewShortDesc = itemView.findViewById(R.id.textViewShortDesc);
textViewtype = itemView.findViewById(R.id.textViewRating);
textViewPrice = itemView.findViewById(R.id.textViewPrice);
imageView = itemView.findViewById(R.id.imageView);
}
}
}
莫回无
暮色呼如
牛魔王的故事
相关分类