解决方法
这已经回答了
here.无论如何,你可以这样做:
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener,View.OnLongClickListener { private Article mArticle; private TextView mNameTextView; public ViewHolder(View itemView) { super(itemView); itemView.setOnClickListener(this); itemView.setOnLongClickListener(this); mNameTextView = (TextView) itemView.findViewById(R.id.grid_item_article_name_textView); } public void bind(Article article) { mArticle = article; mNameTextView.setText(article.getName()); } @Override public void onClick(View view) { // Context context = view.getContext(); // mArticle.getName() } @Override public boolean onLongClick(View view) { // Handle long click } }