When I double-touch (or long press) on the edittext widget it selects some text. The bounds of the selection seem to stop at whitespace. I would like to change this behaviour to stop at punctuation. How would I achieve this?
Asked
Active
Viewed 335 times
3
-
Please your question more. – GrIsHu Jul 18 '14 at 05:40
-
i don't understand ur question. can u specify what u needed. – Nithinlal Jul 18 '14 at 05:42
-
try some thing like this http://stackoverflow.com/a/20988922 – Sree Jul 18 '14 at 05:43
-
Looking over the source code it looks like its handled by the WordIterator. As best as I can tell the default one should be stopping at punctuation, but it doesn't seem to for me. – RadAd Jul 22 '14 at 01:35
1 Answers
0
You can make use of the following:
txtInput.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
int index = txtInput.getText().toString().indexOf("!");
if(index!=-1){
txtInput.setSelection(0, index);
}
return true;
}
});

LMK
- 2,882
- 5
- 28
- 52

Snehal Poyrekar
- 735
- 5
- 17
-
This is partially useful. How do you know where the long press occurs? It would be needed to work which subset of the selection to use. Also, this doesn't address the double tap case. – RadAd Jul 21 '14 at 05:49