I basically wants to understand about LinkMovementMethod class. I am having an Image inside edit text that needs to be clickable. So I used LinkMovementMethod.getInstance for edit text. But because of this LinkMovementMethod object the context menu(long press) options for edit text like copy, cut, paste are not visible. Also i am not able to position cursor in edit text. Somehow the cursor is hiding.
Is it the correct approach to use LinkMovementMethod in edit text or is it necessary to write a custom LinkMovementMethod class for the cursor and context menu problem.
EditText editText = (EditText)findViewById(R.id.text);
editText.setMovementMethod(LinkMovementMethod.getInstance());
-Regards, Ron..
You can also use android:background="@null" . Edit: The TextView 's editable param does make it editable (with some restrictions). If you set android:editable="true" you can access the TextView via the D-pad, or you could add android:focusableInTouchMode="true" to be able to gain focus on touch.
You can use the attribute style="@style/your_style" that is defined for any widget. The attribute parent="@android:style/Widget. EditText" is important because it will ensure that the style being defined extends the basic Android EditText style, thus only properties different from the default style need to be defined.
To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library. If you want to replicate this behaviour without the library, check out the source code for this small method.
You shouldn't use LinkMovementMethod with editable text. LinkMovementMethod is a movement method that lets you move around between links... which is not what you want for a text editor, since you should be using the movement method that moves the cursor around for editing.
What do you expect to do with links in editable text? When you have editable text, tapping on the text puts the cursor at that point to edit it. It doesn't open the link. These are two conflicting things. If you want to have some other behavior, you will need to customize the text view to do something special and figure out how you are going to disambiguate between editing the link text and opening it (for example Google Docs shows you a pop-up to select to open it if you don't want to edit it). But you will need to code this yourself, there is no magic built-in thing that implements this in the current framework.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With