Selection removeSelection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Selection removeSelection method.

This code example shows how to use the following methods:removeSelection, setSelection, getSpanEnd, getSpanStart, getSpans
 
            Layout layout = widget.getLayout();
            int line = layout.getLineForVertical(y);
            int off = layout.getOffsetForHorizontal(line, x);
 
            MyURLSpan[] link = buffer.getSpans(off, off, MyURLSpan.class);
 
            if (link.length != 0) {
                if (action == MotionEvent.ACTION_UP) {
                    if (!mHasPerformedLongPress) {
                        link[0].onClick(widget);
                    } 
                    pressed = false;
                    lastEvent = new float[2];
                } else if (action == MotionEvent.ACTION_DOWN) {
                    pressed = true;
                    lastEvent[0] = event.getX();
                    lastEvent[1] = event.getY();
                    checkForLongClick(link, widget);
                    Selection.setSelection(buffer,

8
CodeRank
This code example shows how to use the following methods:removeSelection, setSelection, getSpanEnd, getSpanStart, getSpans
 
				Layout layout = widget.getLayout();
				int line = layout.getLineForVertical(y);
				int off = layout.getOffsetForHorizontal(line, x);
 
				ClickableSpan[] link = buffer.getSpans(off, off,
						ClickableSpan.class);
 
				if (link.length != 0) {
					if (action == MotionEvent.ACTION_UP) {
						link[0].onClick(widget);
					} else if (action == MotionEvent.ACTION_DOWN) {
						Selection.setSelection(buffer,
								buffer.getSpanStart(link[0]),
								buffer.getSpanEnd(link[0]));
					} 
 
					if (widget instanceof HtmlTextView) {
						((HtmlTextView) widget).linkHit = true;
					} 

6
CodeRank
This code example shows how to use the following methods:removeSelection, setSelection, getSpanEnd, getSpanStart, getSpans
 
            Layout layout = widget.getLayout();
            int line = layout.getLineForVertical(y);
            int off = layout.getOffsetForHorizontal(line, x);
 
            TouchableSpan[] link = buffer.getSpans(off, off, TouchableSpan.class);
 
            if (link.length != 0) {
                if (action == MotionEvent.ACTION_UP) {
                    link[0].onTouch(widget,event); //////// CHANGED HERE
                } else if (action == MotionEvent.ACTION_DOWN) {
                    link[0].onTouch(widget,event); //////// ADDED THIS
                    Selection.setSelection(buffer,
                                           buffer.getSpanStart(link[0]),
                                           buffer.getSpanEnd(link[0]));
                } 
 
                return true; 
            } else { 
                Selection.removeSelection(buffer);

6
CodeRank
This code example shows how to use the following methods:removeSelection, setSelection, getSpanEnd, getSpanStart, getSpans
 
	            Layout layout = widget.getLayout();
	            int line = layout.getLineForVertical(y);
	            int off = layout.getOffsetForHorizontal(line, x);
 
	            ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
 
	            if (link.length != 0) {
	                if (action == MotionEvent.ACTION_UP) {
	                    link[0].onClick(widget);
	                } else if (action == MotionEvent.ACTION_DOWN) {
	                    Selection.setSelection(buffer,
	                                           buffer.getSpanStart(link[0]),
	                                           buffer.getSpanEnd(link[0]));
	                } 
 
	                return true; 
	            } else { 
	            	Selection.removeSelection(buffer);
	            	 

6
CodeRank
This code example shows how to use the following methods:removeSelection, setSelection, getSpanEnd, getSpanStart, getSpans
 
			Layout layout = widget.getLayout();
			int line = layout.getLineForVertical(y);
			int off = layout.getOffsetForHorizontal(line, x);
 
			MyURLSpan[] link = buffer.getSpans(off, off, MyURLSpan.class);
 
			if (link.length != 0) {
				if (action == MotionEvent.ACTION_UP) {
					if (!mHasPerformedLongPress) {
						link[0].onClick(widget);
					} 
					pressed = false;
					lastEvent = new float[2];
				} else if (action == MotionEvent.ACTION_DOWN) {
					pressed = true;
					lastEvent[0] = event.getX();
					lastEvent[1] = event.getY();
					checkForLongClick(link, widget);
					Selection.setSelection(buffer,

5
CodeRank
This code example shows how to use the following methods:removeSelection, getSpans
 
            Layout layout = widget.getLayout();
            int line = layout.getLineForVertical(y);
            int off = layout.getOffsetForHorizontal(line, x);
 
            TouchableSpan[] link = buffer.getSpans(off, off, TouchableSpan.class);
 
            if (link.length != 0) {
                if (action == MotionEvent.ACTION_UP) {
                    link[0].onTouch(widget,event); //////// CHANGED HERE
                }  
//                else if (action == MotionEvent.ACTION_DOWN) { 
//                    link[0].onTouch(widget,event); //////// ADDED THIS 
//                    Selection.setSelection(buffer, 
//                                           buffer.getSpanStart(link[0]), 
//                                           buffer.getSpanEnd(link[0])); 
//                } 
 
                return true; 
            } else { 

5
CodeRank

Related Selection removeSelection Questions & Answers:

removeSelection Method Overview
Remove the selection or cursor, if any, from the text.
See Code Examples for other Android Selection Methods: