3

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?

user3774329
  • 91
  • 1
  • 11
RadAd
  • 194
  • 9

1 Answers1

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