Android SuperscriptSpan - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SuperscriptSpan class.

This code example shows how to use the following methods:
 */ 
public class SuperScriptHandler extends TagNodeHandler { 
 
	public void handleTagNode(TagNode node, SpannableStringBuilder builder, 
			int start, int end, SpanStack spanStack) { 
		spanStack.pushSpan(new SuperscriptSpan(), start, end); 
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        s.setSpan(new TypefaceSpan("monospace"), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <tt>monospace</tt> world</p>\n");
 
        s = new SpannableString("Hello superscript world");
        s.setSpan(new SuperscriptSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <sup>superscript</sup> world</p>\n");
 
        s = new SpannableString("Hello subscript world");
        s.setSpan(new SubscriptSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <sub>subscript</sub> world</p>\n");
 
        s = new SpannableString("Hello underline world");
        s.setSpan(new UnderlineSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <u>underline</u> world</p>\n");
 
        s = new SpannableString("Hello struck world");
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        return getSuperscriptString(base, 0, base.length() - 1);
    } 
 
    public static CharSequence getSuperscriptString(CharSequence base, int startFromIdx, int endAtIdx) {
        SpannableString str = new SpannableString(base);
        str.setSpan(new SuperscriptSpan(), startFromIdx, endAtIdx, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
        return str;
    } 
 
    public static CharSequence getSubscriptString(CharSequence base) {
        return getSubscriptString(base, 0, base.length() - 1);
    } 
 
    public static CharSequence getSubscriptString(CharSequence base, int startFromIdx, int endAtIdx) {
        SpannableString str = new SpannableString(base);
        str.setSpan(new SubscriptSpan(), startFromIdx, endAtIdx, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
        return str;
    } 
 
    /** 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        return getSuperscriptString(base, 0, base.length() - 1);
    } 
 
    public static CharSequence getSuperscriptString(CharSequence base, int startFromIdx, int endAtIdx) {
        SpannableString str = new SpannableString(base);
        str.setSpan(new SuperscriptSpan(), startFromIdx, endAtIdx, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
        return str;
    } 
 
    public static CharSequence getSubscriptString(CharSequence base) {
        return getSubscriptString(base, 0, base.length() - 1);
    } 
 
    public static CharSequence getSubscriptString(CharSequence base, int startFromIdx, int endAtIdx) {
        SpannableString str = new SpannableString(base);
        str.setSpan(new SubscriptSpan(), startFromIdx, endAtIdx, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
        return str;
    } 
 
    /** 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
     * @param starIndex 
     * @param endIndex 
     */ 
    public void getSuperscriptSpan(SpannableString spannableString,
                                   int starIndex, int endIndex) {
        spannableString.setSpan(new SuperscriptSpan(), starIndex, endIndex,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } 
 
    /** 
     * 超级链接(需要添加setMovementMethod方法附加响应) eg:电话,linkType="tel:4155551212" 
     * 邮件,linkType="mailto:webmaster@google.com" 
     * 网络,linkType="http://www.baidu.com" 
     * 短信,使用"sms:"或者"smsto:",linkType="sms:4155551212" 
     * 彩信,使用"mms:"或者"mmsto:",linkType="mms:4155551212" 
     * 地图,linkType="geo:38.899533,-77.036476" 
     * 
     * @param spannableString 
     * @param linkType 
     * @param starIndex 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        s.setSpan(new TypefaceSpan("monospace"), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <tt>monospace</tt> world</p>\n");
 
        s = new SpannableString("Hello superscript world");
        s.setSpan(new SuperscriptSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <sup>superscript</sup> world</p>\n");
 
        s = new SpannableString("Hello subscript world");
        s.setSpan(new SubscriptSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <sub>subscript</sub> world</p>\n");
 
        s = new SpannableString("Hello underline world");
        s.setSpan(new UnderlineSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <u>underline</u> world</p>\n");
 
        s = new SpannableString("Hello struck world");
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	 * @param starIndex 
	 * @param endIndex 
	 */ 
	public void getSuperscriptSpan(SpannableString spannableString,
			int starIndex, int endIndex) {
		spannableString.setSpan(new SuperscriptSpan(), starIndex, endIndex,
				Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
	} 
 
	/** 
	 * 超级链接(需要添加setMovementMethod方法附加响应) eg:电话,linkType="tel:4155551212" 
	 * 邮件,linkType="mailto:webmaster@google.com" 
	 * 网络,linkType="http://www.baidu.com" 
	 * 短信,使用"sms:"或者"smsto:",linkType="sms:4155551212" 
	 * 彩信,使用"mms:"或者"mmsto:",linkType="mms:4155551212" 
	 * 地图,linkType="geo:38.899533,-77.036476" 
	 *  
	 * @param spannableString 
	 * @param linkType 
	 * @param starIndex 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
			} 
		} 
		int length = num.length();
		sb.setSpan(new RelativeSizeSpan((float) 0.5), sb.length() - length, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		sb.setSpan(new ForegroundColorSpan(Color.RED), sb.length() - length, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		sb.setSpan(new SuperscriptSpan(), sb.length() - length, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
 
	} 
	 
	public void markBoundary() { 
		boundaries.add(sb.length());
	} 
	 
//	public void setSwordVerseNum(String num) { 
//		if (num != null) { 
//			sb.append(' ' + num); 
//			int length = num.length(); 
//			sb.setSpan(new AbsoluteSizeSpan(12), sb.length() - length, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 
//			sb.setSpan(new ForegroundColorSpan(Color.RED), sb.length() - length, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 
//			sb.setSpan(new SuperscriptSpan(), sb.length() - length, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        s.setSpan(new TypefaceSpan("monospace"), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <tt>monospace</tt> world</p>\n");
 
        s = new SpannableString("Hello superscript world");
        s.setSpan(new SuperscriptSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <sup>superscript</sup> world</p>\n");
 
        s = new SpannableString("Hello subscript world");
        s.setSpan(new SubscriptSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <sub>subscript</sub> world</p>\n");
 
        s = new SpannableString("Hello underline world");
        s.setSpan(new UnderlineSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <u>underline</u> world</p>\n");
 
        s = new SpannableString("Hello struck world");
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Android SuperscriptSpan Methods: