I have 2 classes, MainActivity and RecyclerAdapter In MainActivity there is a pop-up dialog:
public void DialogClick(View view) { Log.d(TAG, String.valueOf(view.getTag())); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle((CharSequence) mDataSet.get(1)) .setMessage((CharSequence) mDataSet1.get(1)) .setCancelable(false) .setNegativeButton("закрыть", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } In which I want information to appear from the database. But in order to understand on which RecyclerView element the button was pressed, I need to use SetTeg and GetTeg, as I understood. But he gives out a null. Here is the RecyclerAdapter:
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()) .inflate(R.layout.recycler_item, parent, false); ViewHolder vh = new ViewHolder(v); v.setTeg(vh); return vh; }