📜  view.getId 在设置时给出错误 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:54.088000             🧑  作者: Mango

代码示例1
public static class ListMenuRowViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

    protected NetworkImageView thumbnail;
    protected TextView itemname;
    protected TextView price;
    protected TextView itemtype;
    protected TextView quantity;
    protected ImageView add;
    protected ImageView sub;
    protected ImageView imageView;
    protected CardView item_layout;

    public ListMenuRowViewHolder(View itemView) {
        super(itemView);

        this.thumbnail = (NetworkImageView) itemView.findViewById(R.id.recom);
        this.imageView = (ImageView) itemView.findViewById(R.id.categ);
        this.itemname = (TextView) itemView.findViewById(R.id.itemvalue);
        this.add = (ImageView) itemView.findViewById(R.id.add);
        this.sub = (ImageView) itemView.findViewById(R.id.sub);
        this.price = (TextView) itemView.findViewById(R.id.price);
        this.quantity = (TextView) itemView.findViewById(R.id.quantity);

        this.add.setOnClickListener(this);
        this.sub.setOnClickListener(this);
        //Do this for each view
    }

    @Override
    public void onClick(View v) {
        Log.e("myname", "rohit");
        ItemscardClickListener.onClick(v, getAdapterPosition());
    }
}