TextView 在 RecyclerView 中被复用之后,文字不可选中?

TextView does not support text selection. Action mode cancelled.

这貌似是一个 Android platform 的已知bug,解决起来也很简单。
Bug workaround for losing text selection ability, see:
https://code.google.com/p/android/issues/detail?id=208169

1. 在adapter中重写onViewAttachedToWindow方法

@Override
protected void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
        super.onViewAttachedToWindow(holder);

        holder.textView.setEnabled(false);
        holder.textView.setEnabled(true);
    }

2. 在TextView中重写onAttachedToWindow方法

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    this.setEnabled(false);
    this.setEnabled(true);
}
StackOverFlow:

https://stackoverflow.com/questions/37566303/edittext-giving-error-textview-does-not-support-text-selection-selection-canc/40140869

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容