5

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

pRaNaY
  • 24,642
  • 24
  • 96
  • 146
  • You can try with long press. – Pratik Butani Dec 20 '15 at 06:45
  • 1
    What is different about your situation from http://blog.danlew.net/2015/12/14/making-edittexts-with-links-both-clickable-and-editable/ , which says this feature already works the way you want? – Noumenon Dec 20 '15 at 06:56

2 Answers2

3

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

Ilya Tretyakov
  • 6,848
  • 3
  • 28
  • 45
0

check the following code.

EditText inputText;
//Edittext is clickable at right side.
inputText.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            final int DRAWABLE_LEFT = 0;
            final int DRAWABLE_TOP = 1;
            final int DRAWABLE_RIGHT = 2;
            final int DRAWABLE_BOTTOM = 3;

            if (event.getAction() == MotionEvent.ACTION_UP) {
                if (event.getRawX() >= (inputText.getRight() - inputText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                   //write your logic
                    return true;
                }
            }
            return false;
        }
    });
Prathap Badavath
  • 1,621
  • 2
  • 20
  • 24