android.widget.TextView.getUrls()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中android.widget.TextView.getUrls()方法的一些代码示例,展示了TextView.getUrls()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getUrls()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getUrls

TextView.getUrls介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetUrls() throws Exception {
 Locale.setDefault(Locale.ENGLISH);
 textView.setAutoLinkMask(Linkify.ALL);
 textView.setText("here's some text http://google.com/\nblah\thttp://another.com/123?456 blah");
 assertThat(urlStringsFrom(textView.getUrls())).isEqualTo(asList(
     "http://google.com",
     "http://another.com/123?456"
 ));
}

代码示例来源:origin: stackoverflow.com

TextView tv=new TextView(this);
 tv.setLayoutParams(lparams);
 webview =new WebView(this);
 webview.setLayoutParams(lparams);
 tv.setText(Html.fromHtml("<a href='http://www.google.com'>www.google.com</a>"));
 tv.setClickable(true);
 tv.setMovementMethod(LinkMovementMethod.getInstance());
 URLSpan[] urlSpans = tv.getUrls();
 for ( URLSpan urlSpan : urlSpans )  
 {  
   webview.loadUrl( urlSpan.getURL() ); 
 }

代码示例来源:origin: stackoverflow.com

private void swapSpans(TextView textView) {
  Spannable spannable = (Spannable) textView.getText();
  URLSpan[] spans = textView.getUrls();
  for(URLSpan span : spans) {
    if(span.getURL().toString().startsWith("tel:")) {
      spannable.setSpan(new ConfirmSpan(span), spannable.getSpanStart(span), spannable.getSpanEnd(span), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
      spannable.removeSpan(span);
    }
  }
}

代码示例来源:origin: jbruchanov/AnUitor

data.put("Urls", tv.getUrls() != null ? Arrays.toString(tv.getUrls()) : "null");
data.put("HasSelection", tv.hasSelection());
data.put("IsInputMethodTar", tv.isInputMethodTarget());

相关文章

TextView类方法