コード例 #1
0
		/**
	     * Given a snippet string with matching segments surrounded by curly
	     * braces, turn those areas into bold spans, removing the curly braces.
	     */
		public static ISpannable BuildStyledSnippet (Java.Lang.String snippet)
		{
			SpannableStringBuilder builder = new SpannableStringBuilder (snippet);
	
			// Walk through string, inserting bold snippet spans
			int startIndex = -1, endIndex = -1, delta = 0;
			while ((startIndex = snippet.IndexOf('{', endIndex)) != -1) {
				endIndex = snippet.IndexOf ('}', startIndex);
	
				// Remove braces from both sides
				builder.Delete (startIndex - delta, startIndex - delta + 1);
				builder.Delete (endIndex - delta - 1, endIndex - delta);
	
				// Insert bold style
				builder.SetSpan (sBoldSpan, startIndex - delta, endIndex - delta - 1, SpanTypes.ExclusiveExclusive);
	
				delta += 2;
			}
	
			return builder;
		}