Previously, I used this scheme to click on an element entirely:
@Override public void onBindViewHolder(LanguageViewHolder personViewHolder, final int position) personViewHolder.languageName.setText(languages.get(position).name); ((View) personViewHolder.languageName.getParent()).setOnClickListener(view -> listener.onRVItemClick(position)); } Now I have slightly changed the structure and in the onClick method I only know how to click on the id:
@Override public void onClick(View v) { switch (v.getId()) { case languages: if (listener != null) { listener.onItemClick(getAdapterPosition()); } break; } } I tried the switch to contact v.Parent () but I can’t get it to mind. The main idea is not only by id, but by the whole view where this id is located.
holder.itemView.setOnClickListener(this)? - JuriySPb ♦getParentnot to prescribe the same click on all the views that are in the same xml. And the author does it in the upper part of the code, so I understand the difficulty is the transfer of the same functionality to theonClick()method? - MorozovgetParent()than to use the normal way? - eugeneek