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

This code example shows how to use the following methods: getSpanStart, getSpans, length
		assertEquals("https://github.com/Uncodin/bypass", spans[0].getURL());
	} 
	 
	public void testHeaderOrder() { 
		SpannedString spannable = (SpannedString) bypass.markdownToSpannable("Header!!\n--------\nText goes here or something\n*One* **Two** ***Three***\n");
		RelativeSizeSpan[] sizeSpan = spannable.getSpans(0, spannable.length(), RelativeSizeSpan.class);
		assertEquals(1, sizeSpan.length);
		assertEquals(0, spannable.getSpanStart(sizeSpan[0]));
	} 
 
	public void testCodeSpan() { 
		Spannable spannable = (Spannable) bypass.markdownToSpannable("`code`");
		TypefaceSpan[] spans = spannable.getSpans(0, spannable.length(), TypefaceSpan.class);
		assertEquals(1, spans.length);
		assertEquals(0, spannable.getSpanStart(spans[0]));
	} 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
 
        // First test with a SpannableStringBuilder, as opposed to SpannedString 
        checkPostProcess(HtmlUtils.postprocess(getContext(), builder));
 
        // Then pass a SpannedString, which is immutable, but the method should still work. 
        checkPostProcess(HtmlUtils.postprocess(getContext(), new SpannedString(builder)));
    } 
 
    /** 
     * Same as {@link #testPostProcess_with_newlines}, but text has no newlines. 
     * (The internal code path is slightly different.) 
     */ 
    public void testPostProcess_no_newlines() { 
        final SpannableStringBuilder builder = new SpannableStringBuilder("01234");
 
        setSpans(builder);
 
        // First test with a SpannableStringBuilder, as opposed to SpannedString 
        checkPostProcess(HtmlUtils.postprocess(getContext(), builder));
 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
 
        // First test with a SpannableStringBuilder, as opposed to SpannedString 
        checkPostProcess(HtmlUtils.postprocess(getContext(), builder));
 
        // Then pass a SpannedString, which is immutable, but the method should still work. 
        checkPostProcess(HtmlUtils.postprocess(getContext(), new SpannedString(builder)));
    } 
 
    /** 
     * Same as {@link #testPostProcess_with_newlines}, but text has no newlines. 
     * (The internal code path is slightly different.) 
     */ 
    public void testPostProcess_no_newlines() { 
        final SpannableStringBuilder builder = new SpannableStringBuilder("01234");
 
        setSpans(builder);
 
        // First test with a SpannableStringBuilder, as opposed to SpannedString 
        checkPostProcess(HtmlUtils.postprocess(getContext(), builder));
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
        mTextView.myDraw(mCanvas);
    } 
 
    @SmallTest 
    public void testSpan() throws Exception { 
        CharSequence charSeq = new SpannedString(mString);
        mTextView.setText(charSeq);
 
        mTextView.myDraw(mCanvas);
        mTextView.myDraw(mCanvas);
        mTextView.myDraw(mCanvas);
        mTextView.myDraw(mCanvas);
        mTextView.myDraw(mCanvas);
        mTextView.myDraw(mCanvas);
        mTextView.myDraw(mCanvas);
        mTextView.myDraw(mCanvas);
        mTextView.myDraw(mCanvas);
        mTextView.myDraw(mCanvas);
    } 
 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: toHtml
		settings.setDisplayZoomControls(false);
//		settings.setDefaultZoom(WebSettings.ZoomDensity.CLOSE); 
		settings.enableSmoothTransition();
		settings.setDefaultFontSize(14);
		 
		SpannedString s = new SpannedString(TablatureHolder.getInstance().getSelectedTab().getDetails());
		webview.loadData(Html.toHtml(s), "text/html", null);
		return webview;
	} 
 
	private View getLinkView() {
		// url 
		TextView textView2 = new TextView(getActivity());
		textView2.setGravity(Gravity.CENTER);
		textView2.setText(TablatureHolder.getInstance().getSelectedTab().getUrl());
		Linkify.addLinks(textView2, Linkify.ALL);
		return textView2;
	} 
} 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android SpannedString Questions & Answers:

See Code Examples for Android SpannedString Methods: