当前位置: 首页>>代码示例>>C#>>正文


C# android.setSpan方法代码示例

本文整理汇总了C#中android.setSpan方法的典型用法代码示例。如果您正苦于以下问题:C# android.setSpan方法的具体用法?C# android.setSpan怎么用?C# android.setSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android的用法示例。


在下文中一共展示了android.setSpan方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: setSelection

		// private static int pin(int value, int min, int max) {
		//     return value < min ? 0 : (value > max ? max : value);
		// }
		/// <summary>
		/// Set the selection anchor to <code>start</code> and the selection edge
		/// to <code>stop</code>.
		/// </summary>
		/// <remarks>
		/// Set the selection anchor to <code>start</code> and the selection edge
		/// to <code>stop</code>.
		/// </remarks>
		public static void setSelection(android.text.Spannable text, int start, int stop)
		{
			// int len = text.length();
			// start = pin(start, 0, len);  XXX remove unless we really need it
			// stop = pin(stop, 0, len);
			int ostart = getSelectionStart(text);
			int oend = getSelectionEnd(text);
			if (ostart != start || oend != stop)
			{
				text.setSpan(SELECTION_START, start, start, android.text.SpannedClass.SPAN_POINT_POINT
					 | android.text.SpannedClass.SPAN_INTERMEDIATE);
				text.setSpan(SELECTION_END, stop, stop, android.text.SpannedClass.SPAN_POINT_POINT
					);
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:26,代码来源:Selection.cs

示例2: addParagraphSpan

		private static void addParagraphSpan(android.text.Spannable buffer, object what, 
			int start, int end)
		{
			int len = buffer.Length;
			if (start != 0 && start != len && buffer[start - 1] != '\n')
			{
				for (start--; start > 0; start--)
				{
					if (buffer[start - 1] == '\n')
					{
						break;
					}
				}
			}
			if (end != 0 && end != len && buffer[end - 1] != '\n')
			{
				for (end++; end < len; end++)
				{
					if (buffer[end - 1] == '\n')
					{
						break;
					}
				}
			}
			buffer.setSpan(what, start, end, android.text.SpannedClass.SPAN_PARAGRAPH);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:26,代码来源:StringBlock.cs

示例3: onKeyDown


//.........这里部分代码省略.........
					if (selEnd - selStart - 1 == 0)
					{
						char accent = content[selStart];
						int composed = android.view.KeyEvent.getDeadChar(accent, i);
						if (composed != 0)
						{
							i = composed;
							replace = true;
						}
					}
					if (!replace)
					{
						android.text.Selection.setSelection(content, selEnd);
						content.removeSpan(android.text.method.TextKeyListener.ACTIVE);
						selStart = selEnd;
					}
				}
				if ((pref & android.text.method.TextKeyListener.AUTO_CAP) != 0 && Sharpen.CharHelper.IsLower
					(i) && android.text.method.TextKeyListener.shouldCap(mAutoCap, content, selStart
					))
				{
					int where = content.getSpanEnd(android.text.method.TextKeyListener.CAPPED);
					int flags = content.getSpanFlags(android.text.method.TextKeyListener.CAPPED);
					if (where == selStart && (((flags >> 16) & unchecked((int)(0xFFFF))) == i))
					{
						content.removeSpan(android.text.method.TextKeyListener.CAPPED);
					}
					else
					{
						flags = i << 16;
						i = Sharpen.CharHelper.ToUpper(i);
						if (selStart == 0)
						{
							content.setSpan(android.text.method.TextKeyListener.CAPPED, 0, 0, android.text.SpannedClass.SPAN_MARK_MARK
								 | flags);
						}
						else
						{
							content.setSpan(android.text.method.TextKeyListener.CAPPED, selStart - 1, selStart
								, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE | flags);
						}
					}
				}
				if (selStart != selEnd)
				{
					android.text.Selection.setSelection(content, selEnd);
				}
				content.setSpan(OLD_SEL_START, selStart, selStart, android.text.SpannedClass.SPAN_MARK_MARK
					);
				content.replace(selStart, selEnd, java.lang.CharSequenceProxy.Wrap(((char)i).ToString
					()));
				int oldStart = content.getSpanStart(OLD_SEL_START);
				selEnd = android.text.Selection.getSelectionEnd(content);
				if (oldStart < selEnd)
				{
					content.setSpan(android.text.method.TextKeyListener.LAST_TYPED, oldStart, selEnd, 
						android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE);
					if (dead)
					{
						android.text.Selection.setSelection(content, oldStart, selEnd);
						content.setSpan(android.text.method.TextKeyListener.ACTIVE, oldStart, selEnd, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE
							);
					}
				}
				adjustMetaAfterKeypress(content);
				// potentially do autotext replacement if the character
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:67,代码来源:QwertyKeyListener.cs

示例4: markAsReplaced

		/// <summary>
		/// Marks the specified region of <code>content</code> as having
		/// contained <code>original</code> prior to AutoText replacement.
		/// </summary>
		/// <remarks>
		/// Marks the specified region of <code>content</code> as having
		/// contained <code>original</code> prior to AutoText replacement.
		/// Call this method when you have done or are about to do an
		/// AutoText-style replacement on a region of text and want to let
		/// the same mechanism (the user pressing DEL immediately after the
		/// change) undo the replacement.
		/// </remarks>
		/// <param name="content">the Editable text where the replacement was made</param>
		/// <param name="start">the start of the replaced region</param>
		/// <param name="end">the end of the replaced region; the location of the cursor</param>
		/// <param name="original">the text to be restored if the user presses DEL</param>
		public static void markAsReplaced(android.text.Spannable content, int start, int 
			end, string original)
		{
			android.text.method.QwertyKeyListener.Replaced[] repl = content.getSpans<android.text.method.QwertyKeyListener
				.Replaced>(0, content.Length);
			{
				for (int a = 0; a < repl.Length; a++)
				{
					content.removeSpan(repl[a]);
				}
			}
			int len = original.Length;
			char[] orig = new char[len];
			Sharpen.StringHelper.GetCharsForString(original, 0, len, orig, 0);
			content.setSpan(new android.text.method.QwertyKeyListener.Replaced(orig), start, 
				end, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:33,代码来源:QwertyKeyListener.cs

示例5: extendSelection

		/// <summary>Move the selection edge to offset <code>index</code>.</summary>
		/// <remarks>Move the selection edge to offset <code>index</code>.</remarks>
		public static void extendSelection(android.text.Spannable text, int index)
		{
			if (text.getSpanStart(SELECTION_END) != index)
			{
				text.setSpan(SELECTION_END, index, index, android.text.SpannedClass.SPAN_POINT_POINT
					);
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:10,代码来源:Selection.cs

示例6: release

		// no super to call through to
		private void release(android.text.Editable content, object what, android.view.KeyEvent
			 @event)
		{
			int current = content.getSpanFlags(what);
			switch (@event.getKeyCharacterMap().getModifierBehavior())
			{
				case android.view.KeyCharacterMap.MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED:
				{
					if (current == USED)
					{
						content.removeSpan(what);
					}
					else
					{
						if (current == PRESSED)
						{
							content.setSpan(what, 0, 0, RELEASED);
						}
					}
					break;
				}

				default:
				{
					content.removeSpan(what);
					break;
				}
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:30,代码来源:MetaKeyKeyListener.cs

示例7: startSelecting

		/// <summary>Start selecting text.</summary>
		/// <remarks>Start selecting text.</remarks>
		/// <hide>pending API review</hide>
		public static void startSelecting(android.view.View view, android.text.Spannable 
			content)
		{
			content.setSpan(SELECTING, 0, 0, PRESSED);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:8,代码来源:MetaKeyKeyListener.cs

示例8: press

		// no super to call through to
		private void press(android.text.Editable content, object what)
		{
			int state = content.getSpanFlags(what);
			if (state == PRESSED)
			{
			}
			else
			{
				// repeat before use
				if (state == RELEASED)
				{
					content.setSpan(what, 0, 0, LOCKED);
				}
				else
				{
					if (state == USED)
					{
					}
					else
					{
						// repeat after use
						if (state == LOCKED)
						{
							content.removeSpan(what);
						}
						else
						{
							content.setSpan(what, 0, 0, PRESSED);
						}
					}
				}
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:34,代码来源:MetaKeyKeyListener.cs

示例9: adjust

		private static void adjust(android.text.Spannable content, object what)
		{
			int current = content.getSpanFlags(what);
			if (current == PRESSED)
			{
				content.setSpan(what, 0, 0, USED);
			}
			else
			{
				if (current == RELEASED)
				{
					content.removeSpan(what);
				}
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:15,代码来源:MetaKeyKeyListener.cs

示例10: onTouchEvent

		public override bool onTouchEvent(android.widget.TextView widget, android.text.Spannable
			 buffer, android.view.MotionEvent @event)
		{
			int initialScrollX = -1;
			int initialScrollY = -1;
			int action = @event.getAction();
			if (action == android.view.MotionEvent.ACTION_UP)
			{
				initialScrollX = android.text.method.Touch.getInitialScrollX(widget, buffer);
				initialScrollY = android.text.method.Touch.getInitialScrollY(widget, buffer);
			}
			bool handled = android.text.method.Touch.onTouchEvent(widget, buffer, @event);
			if (widget.isFocused() && !widget.didTouchFocusSelect())
			{
				if (action == android.view.MotionEvent.ACTION_DOWN)
				{
					if (isSelecting(buffer))
					{
						int offset = widget.getOffsetForPosition(@event.getX(), @event.getY());
						buffer.setSpan(LAST_TAP_DOWN, offset, offset, android.text.SpannedClass.SPAN_POINT_POINT
							);
						// Disallow intercepting of the touch events, so that
						// users can scroll and select at the same time.
						// without this, users would get booted out of select
						// mode once the view detected it needed to scroll.
						widget.getParent().requestDisallowInterceptTouchEvent(true);
					}
				}
				else
				{
					if (action == android.view.MotionEvent.ACTION_MOVE)
					{
						if (isSelecting(buffer) && handled)
						{
							// Before selecting, make sure we've moved out of the "slop".
							// handled will be true, if we're in select mode AND we're
							// OUT of the slop
							// Turn long press off while we're selecting. User needs to
							// re-tap on the selection to enable long press
							widget.cancelLongPress();
							// Update selection as we're moving the selection area.
							// Get the current touch position
							int offset = widget.getOffsetForPosition(@event.getX(), @event.getY());
							android.text.Selection.extendSelection(buffer, offset);
							return true;
						}
					}
					else
					{
						if (action == android.view.MotionEvent.ACTION_UP)
						{
							// If we have scrolled, then the up shouldn't move the cursor,
							// but we do need to make sure the cursor is still visible at
							// the current scroll offset to avoid the scroll jumping later
							// to show it.
							if ((initialScrollY >= 0 && initialScrollY != widget.getScrollY()) || (initialScrollX
								 >= 0 && initialScrollX != widget.getScrollX()))
							{
								widget.moveCursorToVisibleOffset();
								return true;
							}
							int offset = widget.getOffsetForPosition(@event.getX(), @event.getY());
							if (isSelecting(buffer))
							{
								buffer.removeSpan(LAST_TAP_DOWN);
								android.text.Selection.extendSelection(buffer, offset);
							}
							else
							{
								if (!widget.shouldIgnoreActionUpEvent())
								{
									android.text.Selection.setSelection(buffer, offset);
								}
							}
							android.text.method.MetaKeyKeyListener.adjustMetaAfterKeypress(buffer);
							android.text.method.MetaKeyKeyListener.resetLockedMeta(buffer);
							return true;
						}
					}
				}
			}
			return handled;
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:83,代码来源:ArrowKeyMovementMethod.cs


注:本文中的android.setSpan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。