android – 带有可点击和可编辑链接的EditTexts

android – 带有可点击和可编辑链接的EditTexts,第1张

概述我正在使用EditText,它将WebUrl作为输入.因为我正在使用LinkMovementMethod使EditText中的链接可单击. 问题是: If the last part of the text is a link, clicking anywhere causes the link to be opened. 我想点击这里点击这里编辑区域编辑文本,它会被编辑吗? Daniel Lew 我正在使用EditText,它将WebUrl作为输入.因为我正在使用linkMovementMethod使EditText中的链接可单击.

问题是:

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

我想点击这里点击这里编辑区域编辑文本,它会被编辑吗?

解决方法 DanIEl Lew几天前写了关于它的博客文章.他建议下一个解决方案

// Make links in the EditText clickableeditText.setMovementMethod(linkMovementMethod.getInstance());// Setup my Spannable with clickable URLsSpannable spannable = new SpannableString("http://blog.danlew.net");  linkify.addlinks(spannable,linkify.WEB_URLS);// The fix: Append a zero-wIDth space to the SpannableCharSequence text = TextUtils.concat(spannable,"\u200B");// Use it!editText.setText(text);

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

总结

以上是内存溢出为你收集整理的android – 带有可点击和可编辑链接的EditTexts全部内容,希望文章能够帮你解决android – 带有可点击和可编辑链接的EditTexts所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1127977.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存