我正在使用将 WebUrl 作为输入的 EditText。为此,我正在使用 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 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/