美文网首页
TextView 在 RecyclerView 中被复用之后,文

TextView 在 RecyclerView 中被复用之后,文

作者: 待炒的板栗 | 来源:发表于2018-02-02 14:19 被阅读0次

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

相关文章

网友评论

      本文标题:TextView 在 RecyclerView 中被复用之后,文

      本文链接:https://www.haomeiwen.com/subject/hffezxtx.html