Android UnderlineSpan - 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 UnderlineSpan class.

This code example shows how to use the following methods:
    } 
 
    @Override 
    public void setText(CharSequence text, BufferType type) {
        SpannableString content = new SpannableString(text + " \u00BB");
        content.setSpan(new UnderlineSpan(), 0, text.length(), 0);
 
        super.setText(content, BufferType.SPANNABLE);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
        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");
        s.setSpan(new StrikethroughSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <strike>struck</strike> world</p>\n");
 
        s = new SpannableString("Hello linky world");
        s.setSpan(new URLSpan("http://www.google.com"), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s),
                     "<p>Hello <a href=\"http://www.google.com\">linky</a> world</p>\n"); 
    } 
5
CodeRank
This code example shows how to use the following methods:
     * @param starIndex 
     * @param endIndex 
     */ 
    public void getUnderlineSpan(SpannableString spannableString,
                                 int starIndex, int endIndex) {
        spannableString.setSpan(new UnderlineSpan(), starIndex, endIndex,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } 
 
    /** 
     * 设置删除线 
     * 
     * @param spannableString 
     * @param starIndex 
     * @param endIndex 
     */ 
    public void getStrikethroughSpan(SpannableString spannableString,
                                     int starIndex, int endIndex) {
        spannableString.setSpan(new StrikethroughSpan(), starIndex, endIndex,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
4
CodeRank
This code example shows how to use the following methods:
	 * @param starIndex 
	 * @param endIndex 
	 */ 
	public void getUnderlineSpan(SpannableString spannableString,
			int starIndex, int endIndex) {
		spannableString.setSpan(new UnderlineSpan(), starIndex, endIndex,
				Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
	} 
 
	/** 
	 * 设置删除线 
	 *  
	 * @param spannableString 
	 * @param starIndex 
	 * @param endIndex 
	 */ 
	public void getStrikethroughSpan(SpannableString spannableString,
			int starIndex, int endIndex) {
		spannableString.setSpan(new StrikethroughSpan(), starIndex, endIndex,
				Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
4
CodeRank
This code example shows how to use the following methods:
    } 
     
    protected void setErrorButtonRetryText(CharSequence text) {
        if (mCreated) {
            SpannableString spanString = new SpannableString(text);
            spanString.setSpan(new UnderlineSpan(), 0, spanString.length(), 0);
            mErrorRetryTextView.setText(spanString);
        } 
    } 
     
    private void displayErrorContainer() { 
        if (mCreated) {
            mErrorTextView.setVisibility(View.GONE);
            mErrorRetryTextView.setVisibility(View.GONE);
             
            if (mErrorTextView.getText().length() > 0) {
                mErrorTextView.setVisibility(View.VISIBLE);
            } 
             
//            if (!Application.IsOffline || Application.isOfflineModeForced() 
3
CodeRank
This code example shows how to use the following methods:
			final HandyTextView textView, final int start, final int end) {
		textView.setFocusable(true);
		textView.setClickable(true);
		SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(
				textView.getText().toString().trim());
		spannableStringBuilder.setSpan(new UnderlineSpan(), start, end,
				Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		textView.setText(spannableStringBuilder);
	} 
 
	/** 
	 * 获取括号中的国家区号 
	 *  
	 * @param text 
	 *            带有括号的国家区号 
	 * @param defaultText 
	 *            默认的国家区号(在获取错误时返回该值) 
	 * @return 
	 */ 
	public static String getCountryCodeBracketsInfo(String text,
4
CodeRank
This code example shows how to use the following methods:
        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");
        s.setSpan(new StrikethroughSpan(), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s), "<p>Hello <strike>struck</strike> world</p>\n");
 
        s = new SpannableString("Hello linky world");
        s.setSpan(new URLSpan("http://www.google.com"), 6, s.length() - 6,
                  Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        assertEquals(Html.toHtml(s),
                     "<p>Hello <a href=\"http://www.google.com\">linky</a> world</p>\n"); 
    } 
4
CodeRank
This code example shows how to use the following methods:
    } 
 
    private static int format4(String text, int start, StringBuilder sb, List<StyleWithRegion> styles) {
        int end = text.indexOf('\n', start);
        if(end != -1) {
            styles.add(new StyleWithRegion(new UnderlineSpan(), sb.length()+4, sb.length()+end-start));
            styles.add(new StyleWithRegion(new ForegroundColorSpan(Color.CYAN), sb.length()+4, sb.length()+end-start));
            sb.append(text.substring(start,end)+"\n");
        } else { 
            end = start;
        } 
        return end;
    } 
 
    private static int format5(String text, int start, StringBuilder sb, List<StyleWithRegion> styles) {
        int end = text.indexOf('>', start);
        if(end != -1) {
            styles.add(new StyleWithRegion(new StyleSpan(Typeface.BOLD), sb.length(), sb.length()+end-start));
            styles.add(new StyleWithRegion(new ForegroundColorSpan(Color.GREEN), sb.length(), sb.length()+end-start));
            sb.append(text.substring(start,end));
4
CodeRank
This code example shows how to use the following methods:
        initNative(); 
    } 
     
    @Override 
    public Object getSpan(String text, SpanSpec spec, Object arg) {
        return new UnderlineSpan();
    } 
} 
5
CodeRank
This code example shows how to use the following methods:

Related Android UnderlineSpan Questions & Answers:

See Code Examples for Android UnderlineSpan Methods: