简体   繁体   English

Android TextView:需要长按时选择文本,而不仅仅是双击

[英]Android TextView : Need text selection on Long Press not just double tap

I have a TextView that is supposed to be clickable, selectable and linkified . 我有一个TextView ,应该可以单击, selectablelinkified Up until a month ago, setting 直到一个月前,

textView.setTextIsSelectable(true); 
textView.setMovementMethod(ArrowKeyMovementMethod.getInstance());

would cause long press to show the copy/paste actions in the Actionbar . 将导致长按以在操作Actionbar显示copy/paste操作。 But now somehow, the copy/paste only shows on double tap and not on long press. 但是现在不知何故, copy/paste仅在双击时显示,而在长按时不显示。 Long press does nothing. 长按不起作用。 I really need for it to show on long press and not on double tap. 我真的需要长按而不是双击显示它。 Please help !!! 请帮忙 !!!

Ok. 好。 Figured it out. 弄清楚了。 There was a long click listener on the listview which was not doing anything since there was no long press defined for the listview. 列表视图上有一个长按侦听器,它没有做任何事情,因为没有为列表视图定义长按。 Although the clicks were properly delegated first to the textview before the list, the long presses were not. 尽管单击已正确地首先委派给了列表之前的textview,但长按却没有。 So in the onItemLongClick method, I return false to allow propogation to the textview 因此,在onItemLongClick方法中,我返回false以允许传播到textview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM