How to get selected text from edittext in android?

android, android-emulator, android-intent, android-layout, android-widget

Solution

EditText et=(EditText)findViewById(R.id.edit);

int startSelection=et.getSelectionStart();
int endSelection=et.getSelectionEnd();

String selectedText = et.getText().toString().substring(startSelection, endSelection);

Problem

I have a edittext in which some text are selected . I want to get only selected text from edittext on click of button . Please suggest me usable link or sample code.

Original source

Related problems