0

Is possible to determine if user selected some text in EditText? If yes, is possible to determine which text? How?

I am programming something like text editor and i need set some text as header when user select it and click on button which is under edit text

thx for help

Mr. Robot
  • 575
  • 2
  • 6
  • 19

1 Answers1

3

Try this:

int startSelection=et.getSelectionStart();
int endSelection=et.getSelectionEnd();
String selectedText = et.getText().substring(startSelection, endSelection);

See this question: Android - get selection of text from EditText

Community
  • 1
  • 1
Jannik
  • 2,310
  • 6
  • 32
  • 61
  • exits something like onSelectionListener? I want to show the button if user is selecting or just selected – Mr. Robot Dec 15 '14 at 06:44
  • 1
    I think I overread your basic question, I am sorry. Yeah, I am no Android programmer, but I think there might be something like that: http://stackoverflow.com/questions/10188392/text-selection-listener-in-androidapi-level-7 – Jannik Dec 15 '14 at 06:49