本文整理了Java中android.widget.TextView.setLinksClickable()
方法的一些代码示例,展示了TextView.setLinksClickable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setLinksClickable()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setLinksClickable
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void testLinksClickable() {
assertThat(textView.getLinksClickable()).isTrue();
textView.setLinksClickable(false);
assertThat(textView.getLinksClickable()).isFalse();
textView.setLinksClickable(true);
assertThat(textView.getLinksClickable()).isTrue();
}
代码示例来源:origin: stackoverflow.com
void setLinks(TextView tv, String text) {
String[] linkPatterns = {
"([Hh][tT][tT][pP][sS]?:\\/\\/[^ ,'\">\\]\\)]*[^\\. ,'\">\\]\\)])",
"#[\\w]+", "@[\\w]+" };
for (String str : linkPatterns) {
Pattern pattern = Pattern.compile(str);
Matcher matcher = pattern.matcher(tv.getText());
while (matcher.find()) {
int x = matcher.start();
int y = matcher.end();
final android.text.SpannableString f = new android.text.SpannableString(
tv.getText());
InternalURLSpan span = new InternalURLSpan();
span.text = text.substring(x, y);
f.setSpan(span, x, y,
android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(f);
// tv.setOnLongClickListener(span.l);
}
}
tv.setLinkTextColor(Color.BLUE);
tv.setLinksClickable(true);
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setFocusable(false);
}
代码示例来源:origin: stackoverflow.com
TextView txt = ...
txt.setLinksClickable(true);
txt.setText(SafeURLSpan.parseSafeHtml(<<YOUR STRING GOES HERE>>));
txt.setMovementMethod(LinkMovementMethod.getInstance());
代码示例来源:origin: stackoverflow.com
TextView txt = ...
txt.setLinksClickable(true);
txt.setText(SafeURLSpan.parseSafeHtml(<<YOUR STRING GOES HERE>>));
txt.setMovementMethod(LinkMovementMethod.getInstance());
代码示例来源:origin: stackoverflow.com
final SpannableStringBuilder content = getContent(); // This method is explained below.
final TextView textView = (TextView) findViewById(R.id.my_text_view);
textView.setLinksClickable(true);
textView.setText(content, TextView.BufferType.SPANNABLE);
textView.setMovementMethod(LinkMovementMethod.getInstance());
代码示例来源:origin: stackoverflow.com
TextView tv_contatti2 = new TextView(this); tv_contatti2.setText(contatti);
Linkify.addLinks(tv_contatti2, Linkify.PHONE_NUMBERS);
tv_contatti2.setLinksClickable(true);
代码示例来源:origin: stackoverflow.com
TextView textView = (TextView) findViewById(R.id.text_link);
textView.setLinkTextColor(getResources().getColorStateList(R.color.link_color));
textView.setLinksClickable(true);
textView.setClickable(true);
textView.setText(Html.fromHtml("<a href=\"http://www.google.com\">Google</a>"));
代码示例来源:origin: stackoverflow.com
TextView textView = (TextView) view.findViewById(R.id.link_tv);
textView.setLinkTextColor(getResources().getColorStateList(
R.drawable.text_selector));
textView.setLinksClickable(true);
textView.setClickable(true);
textView.setAutoLinkMask(Linkify.WEB_URLS);
textView.setText("www.dummytext.com");
代码示例来源:origin: stackoverflow.com
private Bitmap loadBitmap(int width, int height, int index) {
Bitmap txtBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
String text1 = yourPagesStringArray[index];
Canvas c = new Canvas(txtBitmap);
TextView tv = new TextView(getApplicationContext());
tv.setText(text1);
tv.setTextColor(0xa00050ff);
tv.setTextSize(15);
tv.setLinksClickable(true);
tv.setLineSpacing(2, 2);
tv.layout(0, 0, getResources().getDisplayMetrics().widthPixels, getResources().getDisplayMetrics().heightPixels);
tv.draw(c);
c.drawBitmap(txtBitmap, 0, 0, null);
return txtBitmap;
}
代码示例来源:origin: CityZenApp/Android-Development
private View inflateRowItem(String title, String value) {
View view;
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.detailed_poi_tagitem, null);
//LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.rowContainer);
TextView titleTextView = (TextView) view.findViewById(R.id.rowTitle);
TextView valueTextView = (TextView) view.findViewById(R.id.rowValue);
titleTextView.setText(title);
valueTextView.setText(value);
//Linking content
if (title.toLowerCase().equals("email") || title.toLowerCase().equals("contact:email")) {
Linkify.addLinks(valueTextView, Linkify.EMAIL_ADDRESSES);
valueTextView.setLinksClickable(true);
}
if (title.toLowerCase().equals("website") || title.toLowerCase().equals("contact:website")) {
Linkify.addLinks(valueTextView, Linkify.WEB_URLS);
valueTextView.setLinksClickable(true);
}
if (title.toLowerCase().equals("phone") || title.toLowerCase().equals("phone:mobile") || title.toLowerCase().equals("contact:mobile") || title.toLowerCase().equals("contact:phone")) {
Linkify.addLinks(valueTextView, Linkify.PHONE_NUMBERS);
valueTextView.setLinksClickable(true);
}
return view;
}
代码示例来源:origin: stackoverflow.com
void setLinks(TextView tv, String text) {
String[] linkPatterns = {
"([Hh][tT][tT][pP][sS]?:\\/\\/[^ ,'\">\\]\\)]*[^\\. ,'\">\\]\\)])",
"#[\\w]+", "@[\\w]+" };
for (String str : linkPatterns) {
Pattern pattern = Pattern.compile(str);
Matcher matcher = pattern.matcher(tv.getText());
while (matcher.find()) {
int x = matcher.start();
int y = matcher.end();
final android.text.SpannableString f = new android.text.SpannableString(
tv.getText());
InternalURLSpan span = new InternalURLSpan(context);
span.text = text.substring(x, y);
f.setSpan(span, x, y,
android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(f);
// tv.setOnLongClickListener(span.l);
}
}
tv.setLinkTextColor(Color.BLUE);
tv.setLinksClickable(true);
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setFocusable(false);
}
代码示例来源:origin: casific/murmur
textView.setLinksClickable(!selectionMode);
textView.setMovementMethod(selectionMode ? null : LinkMovementMethod.getInstance());
代码示例来源:origin: pocmo/Yaaic
/**
* Render message as text view
*
* @param context
* @return
*/
public TextView renderTextView(Context context, TextView view)
{
if (view == null) {
view = new TextView(context);
}
view.setAutoLinkMask(Linkify.ALL);
view.setLinksClickable(true);
view.setLinkTextColor(COLOR_BLUE);
view.setText(this.render(context));
view.setTextIsSelectable(true);
return view;
}
代码示例来源:origin: stackoverflow.com
final TextView textView = (TextView) findViewById(R.id.text);
final CharSequence text = textView.getText();
final SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
final URLSpan[] spans = spannableStringBuilder.getSpans(0, text.length(), URLSpan.class);
final URLSpan span = spans[0];
final int start = spannableStringBuilder.getSpanStart(span);
final int end = spannableStringBuilder.getSpanEnd(span);
final int flags = spannableStringBuilder.getSpanFlags(span);
final ClickableSpan clickableSpan = new ClickableSpan() {
public void onClick(View view) {
Log.d(TAG, "Clicked: " + span.getURL());
}
};
spannableStringBuilder.setSpan(clickableSpan, start, end, flags);
spannableStringBuilder.removeSpan(span);
textView.setText(spannableStringBuilder);
textView.setLinksClickable(true);
textView.setMovementMethod(LinkMovementMethod.getInstance());
代码示例来源:origin: stackoverflow.com
TextView preSpoilerTextView = new TextView(context);
TextView postSpoilerTextView = new TextView(context);
spoilerTextView.setLinksClickable(true);
preSpoilerTextView.setLinksClickable(true);
postSpoilerTextView.setLinksClickable(true);
spoilerTextView.setAutoLinkMask(Linkify.WEB_URLS);
preSpoilerTextView.setAutoLinkMask(Linkify.WEB_URLS);
代码示例来源:origin: andstatus/andstatus
public static void showSpannable(TextView textView, @NonNull Spannable spannable, boolean showIfEmpty) {
if (textView == null) return;
if (spannable.length() == 0) {
textView.setText("");
ViewUtils.showView(textView, showIfEmpty);
} else {
textView.setText(spannable);
if (hasSpans(spannable)) {
textView.setFocusable(true);
textView.setFocusableInTouchMode(true);
textView.setLinksClickable(true);
setOnTouchListener(textView);
}
ViewUtils.showView(textView, true);
}
}
代码示例来源:origin: shusain93/Andromeda-iMessage
messageText.setLinksClickable(true);
代码示例来源:origin: shusain93/Andromeda-iMessage
messageText.setLinksClickable(true);
代码示例来源:origin: easemob/kefu-android-demo
contentView.setLinksClickable(true);
contentView.setMovementMethod(LinkMovementMethod.getInstance());
代码示例来源:origin: jelic98/dynamico
textView.setLinksClickable(attributes.getBoolean("linksClickable"));
内容来源于网络,如有侵权,请联系作者删除!