Skip to content

Instantly share code, notes, and snippets.

@serso
Created August 10, 2015 11:39
Show Gist options
  • Save serso/5c3f3f6f6a3073f5bd64 to your computer and use it in GitHub Desktop.
Save serso/5c3f3f6f6a3073f5bd64 to your computer and use it in GitHub Desktop.
EditText for tydlig
private class MyEditText extends EditText {
public MyEditText() {
super(EasyEditSpanActivity.this);
}
@Override
protected void onSelectionChanged(int selStart, int selEnd) {
super.onSelectionChanged(selStart, selEnd);
if (selStart == -1 || selEnd == -1) {
return;
}
final Editable text = getText();
ClickableSpan[] spans = text.getSpans(selStart, selEnd, ClickableSpan.class);
if(spans.length > 0) {
final int spanStart = text.getSpanStart(spans[0]);
if (spanStart != selStart || spanStart != selEnd) {
Selection.setSelection(text, spanStart);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment