gpt4 book ai didi

android - 编辑带有可点击和可编辑链接的文本

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:21:43 25 4
gpt4 key购买 nike

我正在使用将 WebUrl 作为输入的 EditText。为此,我正在使用 LinkMovementMethod 使 EditText 中的链接可点击。

问题是:

If the last part of the text is a link, clicking anywhere causes the link to be opened.

我想当我点击点击此处编辑区域编辑文本时,它将是可编辑的?

enter image description here

最佳答案

Daniel Lew 几天前写了一篇关于它的博文。他建议下一个解决方案:

// Make links in the EditText clickable
editText.setMovementMethod(LinkMovementMethod.getInstance());

// Setup my Spannable with clickable URLs
Spannable spannable = new SpannableString("http://blog.danlew.net");
Linkify.addLinks(spannable, Linkify.WEB_URLS);

// The fix: Append a zero-width space to the Spannable
CharSequence text = TextUtils.concat(spannable, "\u200B");

// Use it!
editText.setText(text);

您可以在这里找到帖子:Making EditTexts with links both clickable and editable

关于android - 编辑带有可点击和可编辑链接的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34378602/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com