Created
August 10, 2015 11:39
-
-
Save serso/5c3f3f6f6a3073f5bd64 to your computer and use it in GitHub Desktop.
EditText for tydlig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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