Made onClick() in onBindViewHolder() , but there is a small problem. It turns out NullPointerExeption, but logging works fine, gives all positions, stumbles on the dialogue, I think this is possible because of the context , I asked it this way:
public Context context; I set it this way, because neither getContext() nor anything else works.
C onBindViewHolder() :
@Override public void onBindViewHolder(final ViewHolder holder, int position) { holder.mTextView.setText(mDataset.get(position)); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d(TAG, "position = " + holder.getAdapterPosition()); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("tittle") .setMessage("hi") .setCancelable(false) .setNegativeButton("закрыть", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } }); } PS I just pointed it to the base of the class, as I wrote above (as suggested by Android Studio). I'm pretty sure that because of this is null , but I don't know how else to get the Context . Previously, it always saved getContext() , getActivity() in such cases.