Android - get selection of text from EditText
android, android-edittext, selection
Solution
Seems like you've already done the hard part by finding what the selected area is. Now you just need to pull that substring out of the full text.
Try this:
String selectedText = et.getText().substring(startSelection, endSelection);
It's just a basic Java String operation.
Problem
I'm trying to implement a copy/paste function. How can I get a selection of text from an EditText? ``` EditText et=(EditText)findViewById(R.id.title); ``` blabla onclicklistener on a button: ``` int startSelection=et.getSelectionStart(); int endSelection=et.getSelectionEnd(); ``` Then I'm stuck. Any ideas?