Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditTexts with links both clickable and editable

I am working with EditText which take WebUrl in input.For that I am using LinkMovementMethod Make links in the EditText clickable.

Problem is that :

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

I want when I am clicking on click here to edit area edittext, It will be editable?

enter image description here

like image 240
pRaNaY Avatar asked Oct 19 '22 19:10

pRaNaY


1 Answers

Daniel Lew wrote the blog post about it several days ago. He suggests next solution:

// 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); 

You can find post here: Making EditTexts with links both clickable and editable

like image 187
Ilya Tretyakov Avatar answered Oct 30 '22 22:10

Ilya Tretyakov