kiwijus
kiwijus

Reputation: 1237

Android EditText Select Text

I have overridden the

OnLongClickListener

of the Android:EditText in order to show my own menu. However I would still like the user to be able to "select text" and "select all" from a button within my custom menu, how should I go about doing that?

EDIT: Sorry I should have put more detail in my question.

I have tried the selectAll() method for selecting the text however this doesn't come up with the two pointers (where the user can drag to select areas) which is what I mean by select text.

Upvotes: 0

Views: 2801

Answers (2)

Jane
Jane

Reputation: 39

Use findViewBy id to find that EditText when your custom button is pressed then use the following function:

((EditText)v).selectAll();

Upvotes: 3

Sam
Sam

Reputation: 86948

In the Related column I found Select all text inside EditText when it gets focus which is easily adaptable to a context menu, you might find "select word" tactics there too.

Upvotes: 1

Related Questions