Code example for Spannable

Methods: removeSelection, removeSpan, setSpan

0
    @Override 
    public void onTakeFocus(TextView view, Spannable text, int dir) {
        this.removeSelection(text);
 
        if ((dir & View.FOCUS_BACKWARD) != 0) {
            text.setSpan(FROM_BELOW, 0, 0, Spanned.SPAN_POINT_POINT);
        } else { 
            text.removeSpan(FROM_BELOW);
        } 
    } 
 
    public static MyLinkMovementMethod getInstance() { 
        if (sInstance == null) {
            sInstance = new MyLinkMovementMethod();
        } 
 
        return sInstance;
    } 
     
    private void removeSelection(Spannable text) {
        Selection.removeSelection(text);
    } 
 
    private static MyLinkMovementMethod sInstance;
    private static Object FROM_BELOW = new NoCopySpan.Concrete();
}