简体   繁体   English

如何在长按或点击时获得点击文本?

[英]How can i get clicked text on long press or on click?

I have one TextView, I want to get the text what user clicked by long press in TextView.我有一个 TextView,我想获取用户在 TextView 中长按点击的文本。

TextView is already selectable. TextView 已经是可选的。

Suppose there is the line "This is my book" in TextView.假设 TextView 中有一行“这是我的书”。 If user click(select) on "book", I want to get that word on long press or onclick.如果用户点击(选择)“书”,我想通过长按或点击获得该词。

can somebody please help?有人可以帮忙吗?

Inside your Text View tag place在您的文本视图标签位置内

android:textIsSelectable=true android:textIsSelectable=true

you can also change the selected text highlighted color.您还可以更改所选文本突出显示的颜色。

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

相关问题 如何在菜单项上捕获长按? - How can I capture a long press on a Menu Item? 如何多次点击按钮点击功能? - how can I make a button click function be clicked multiple times? 如何通过长按示例键盘的键来打开“首选项”屏幕? - How can I open Preference screen by long press from a key of sample keyboard? 如何长按Android应用程序删除ListView和服务器端数据库中的内容(复选框)? - How can I delete content (CheckBox) in a ListView and on a serverside database with long press for android application? 我们可以将ClickHandler和KeyDownHandler添加到具有图像的同一PushButton吗? 我收到了单击事件,但未捕获按键事件 - Can we add a ClickHandler and a KeyDownHandler to the same PushButton with an image? I get the click events but the key press event is not captured 如何为 AppWidgetHostView 制作长按侦听器 - How can I make a long click listener for an AppWidgetHostView 单击按钮时如何启用文本字段? - How can I enable a text field when a button is clicked? 当我单击工具栏后按时,我如何 go 从片段 B 回到 A? - How can i go back to A from fragment B when I click on the toolbar back press? 如何通过单击按钮更改文本? - How can I change the text with a button click? 如何获得从网格单击的组件? - How can I get the component I clicked on from a grid?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM