I know that setting android:textIsSelectable=\"true\"
in xml for the TextView
will show the native text selection popup and I\'ve been using that i
There seems to be many that have problems with this and indications that it may be a bug in the Android code but I don't have a problem. This is what works for me both for an OnClickListener()
and the native selection popup. (Tested on KitKat 4.4, Lollipop 5.1 and Nougat 7.1)
In the adapter
class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView textView;
ImageView imageView;
MyViewHolder(View itemView) {
super(itemView);
textView = (TextView) itemView.findViewById(R.id.my_text_view);
imageView = (ImageView) itemView.findViewById(R.id.my_image_view);
itemView.setOnClickListener(this);
textView.setOnClickListener(this);
}
@Override
public void onClick(View view) {
// this shows 'my_text_view' when the text is clicked or
// 'my_item' if elsewhere is clicked
Log.d(TAG, "view = " + view.toString());
switch (view.getId()) {
case R.id.my_item:
break;
case R.id.my_text_view:
break;
}
}
}
And my item layout