如您所见,“ OnClick”和imageView都为红色。.我不知道如何解决它,有人可以帮我吗?
错误:
无法解析方法'onClick(android.view.View,int,boolean)' 无法解析符号“ imageView”
代码如下:
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import pt.terohost.a2zgreen.R;
public class MenuViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView txtMenuName;
public ImageView imageView;
private AdapterView.OnItemClickListener itemClickListener;
public MenuViewHolder(@NonNull View itemView) {
super(itemView);
txtMenuName = (TextView) itemView.findViewById(R.id.menu_name);
imageView = (ImageView)itemView.findViewById(R.id.imageView); //era imageView mas não dá
itemView.setOnClickListener(this);
}
public void setItemClickListener(AdapterView.OnItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
@Override
public void onClick(View view) {
itemClickListener.onClick(view,getAdapterPosition(),false);
}
}