【发布时间】:2016-04-22 19:02:27
【问题描述】:
我知道在TextView 的xml 中设置android:textIsSelectable="true" 将显示本机文本选择弹出窗口,我一直在我的应用程序中使用它。但是当我尝试在附加到RecyclerView 的视图中设置相同的属性时,我发现它不再起作用了。
每当我尝试选择文本时,都会出现以下日志 -
TextView: TextView does not support text selection. Action mode cancelled.
我不知道为什么?为什么它适用于其他屏幕而不适用于RecyclerView。我阅读了多篇文章-
TextView with android:textIsSelectable="true" not working in listview
textview textIsSelectable="true" not working in Listview
android:textIsSelectable="true" for TextView inside Listview does not work
但后来我遇到了这个帖子-
Android: "TextView does not support text selection. Action mode cancelled"
@hungkk 的回复对我有用。他的解决方案建议将TextView 宽度从match_parent 更改为wrap_content。
我知道我可以做到这一点,但我的问题是这如何解决问题,因为它对我来说看起来很奇怪。另外,如果我想保持宽度为match_parent,解决方案是什么。
欢迎提出任何意见。
【问题讨论】:
-
你在做什么选择? (马蒂或沙达布)。我对
match_parent或wrap_content使用View.OnClickListener()没有任何问题。 -
奇怪,但我在一些帖子中读到,当回收者的视图重用单元格时,如果 TextView 设置为 match_parent,它会禁用可选文本功能。您是否尝试过设置
android:inputType="textMultiLine"'而不是android:textIsSelectable="true"作为解决方法?
标签: android android-recyclerview textview