当前位置: 首页>>代码示例>>Java>>正文


Java Linkify类代码示例

本文整理汇总了Java中android.text.util.Linkify的典型用法代码示例。如果您正苦于以下问题:Java Linkify类的具体用法?Java Linkify怎么用?Java Linkify使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Linkify类属于android.text.util包,在下文中一共展示了Linkify类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAboutDialog

import android.text.util.Linkify; //导入依赖的package包/类
/**
 * @brief Shows the dialog to indicate about info
 * @return The new dialog
 * @details Shows the dialog to indicate about info
 */
private Dialog createAboutDialog()
 {
	//necesario para poder clicar en los links
	final TextView message = new TextView(this);
	final SpannableString s = 
               new SpannableString(this.getText(R.string.about_message));
  Linkify.addLinks(s, Linkify.WEB_URLS);
  message.setText(s);
  message.setMovementMethod(LinkMovementMethod.getInstance());
  
  return new AlertDialog.Builder(this)
  .setTitle(R.string.about_title)
  .setView(message)
  .setPositiveButton(R.string.about_ok,
   new DialogInterface.OnClickListener() {
    
    @Override
    public void onClick(DialogInterface dialog, int which) {
     // Auto-generated method stub
     
    }
   }
    )
  .show();
 }
 
开发者ID:CodyyAndroid,项目名称:LibVNCAndroid,代码行数:31,代码来源:ActivityTabs.java

示例2: linkifyHtml

import android.text.util.Linkify; //导入依赖的package包/类
/**
 * Taken from Stack Overflow - https://stackoverflow.com/a/17201376/6052295
 * Adds links to a HTML string
 *
 * @param html        the HTML string to add links to
 * @param linkifyMask the link type
 * @return The spannable text with clickable links
 */

public static Spannable linkifyHtml(String html, int linkifyMask) {
    Spanned text = fromHtml(fromHtml(html).toString());
    URLSpan[] currentSpans = text.getSpans(0, text.length(), URLSpan.class);

    SpannableString buffer = new SpannableString(text);
    Linkify.addLinks(buffer, linkifyMask);

    for (URLSpan span : currentSpans) {
        int end = text.getSpanEnd(span);
        int start = text.getSpanStart(span);
        buffer.setSpan(span, start, end, 0);
    }
    return buffer;
}
 
开发者ID:jthomperoo,项目名称:Forge,代码行数:24,代码来源:GeneratorFragment.java

示例3: displayShareInfo

import android.text.util.Linkify; //导入依赖的package包/类
private void displayShareInfo(final Share share)
{
	final TextView textView = new TextView(this);
	textView.setPadding(5, 5, 5, 5);

	final Spannable message = new SpannableString("Owner: " + share.getUsername() +
			"\nComments: " + ((share.getDescription() == null) ? "" : share.getDescription()) +
			"\nURL: " + share.getUrl() +
			"\nEntry Count: " + share.getEntries().size() +
			"\nVisit Count: " + share.getVisitCount() +
			((share.getCreated() == null) ? "" : ("\nCreation Date: " + share.getCreated().replace('T', ' '))) +
			((share.getLastVisited() == null) ? "" : ("\nLast Visited Date: " + share.getLastVisited().replace('T', ' '))) +
			((share.getExpires() == null) ? "" : ("\nExpiration Date: " + share.getExpires().replace('T', ' '))));

	Linkify.addLinks(message, Linkify.WEB_URLS);
	textView.setText(message);
	textView.setMovementMethod(LinkMovementMethod.getInstance());

	new AlertDialog.Builder(this).setTitle("Share Details").setCancelable(true).setIcon(android.R.drawable.ic_dialog_info).setView(textView).show();
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:21,代码来源:ShareActivity.java

示例4: displayPlaylistInfo

import android.text.util.Linkify; //导入依赖的package包/类
private void displayPlaylistInfo(final Playlist playlist)
{
	final TextView textView = new TextView(this);
	textView.setPadding(5, 5, 5, 5);

	final Spannable message = new SpannableString("Owner: " + playlist.getOwner() + "\nComments: " +
			((playlist.getComment() == null) ? "" : playlist.getComment()) +
			"\nSong Count: " + playlist.getSongCount() +
			((playlist.getPublic() == null) ? "" : ("\nPublic: " + playlist.getPublic()) + ((playlist.getCreated() == null) ? "" : ("\nCreation Date: " + playlist.getCreated().replace('T', ' ')))));

	Linkify.addLinks(message, Linkify.WEB_URLS);
	textView.setText(message);
	textView.setMovementMethod(LinkMovementMethod.getInstance());

	new AlertDialog.Builder(this).setTitle(playlist.getName()).setCancelable(true).setIcon(android.R.drawable.ic_dialog_info).setView(textView).show();
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:17,代码来源:SelectPlaylistActivity.java

示例5: setCustomMessage

import android.text.util.Linkify; //导入依赖的package包/类
/**
 * 显示富文本消息
 *
 * @param textView
 * @param message
 */
public static void setCustomMessage(TextView textView, String message) {
    JSONObject jsonObject = SafeJson.parseObj(message);
    if (SafeJson.isContainKey(jsonObject, CustomField.TYPE)) {
        String type = SafeJson.safeGet(jsonObject, CustomField.TYPE);
        if (TextUtils.equals(CustomField.VIDEO, type)) {
            if (SafeJson.isContainKey(jsonObject, CustomField.VISITOR_URL)) {
                String url = SafeJson.safeGet(jsonObject, CustomField.VISITOR_URL);
                textView.setText(makeUrlWithHtmlHref(url, textView.getContext().getString(R.string.kf5_invite_video_chat)));
            } else {
                textView.setText(resolveTextWithHtmlTag(message));
            }
        } else {
            textView.setText(resolveTextWithHtmlTag(message));
        }
    } else {
        textView.setText(resolveTextWithHtmlTag(message));
    }
    dealCustomLink(textView);
    Linkify.addLinks(textView, Linkify.ALL);
    textView.setMovementMethod(new CustomLinkMovementMethod());
    dealCustomLink(textView);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:29,代码来源:CustomTextView.java

示例6: inflateRowItem

import android.text.util.Linkify; //导入依赖的package包/类
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;
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:26,代码来源:PoiDetailsFragment.java

示例7: setInteractionState

import android.text.util.Linkify; //导入依赖的package包/类
private void setInteractionState(MessageRecord messageRecord) {
  setSelected(batchSelected.contains(messageRecord));
  bodyText.setAutoLinkMask(batchSelected.isEmpty() ? Linkify.ALL : 0);

  if (mediaThumbnailStub.resolved()) {
    mediaThumbnailStub.get().setFocusable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
    mediaThumbnailStub.get().setClickable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
    mediaThumbnailStub.get().setLongClickable(batchSelected.isEmpty());
  }

  if (audioViewStub.resolved()) {
    audioViewStub.get().setFocusable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
    audioViewStub.get().setClickable(batchSelected.isEmpty());
    audioViewStub.get().setEnabled(batchSelected.isEmpty());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:17,代码来源:ConversationItem.java

示例8: generateLinkDescription

import android.text.util.Linkify; //导入依赖的package包/类
public void generateLinkDescription() {
    if (linkDescription != null) {
        return;
    }
    if (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageOwner.media.webpage instanceof TLRPC.TL_webPage && messageOwner.media.webpage.description != null) {
        linkDescription = Spannable.Factory.getInstance().newSpannable(messageOwner.media.webpage.description);
        if (containsUrls(linkDescription)) {
            try {
                Linkify.addLinks((Spannable) linkDescription, Linkify.WEB_URLS);
            } catch (Exception e) {
                FileLog.e("tmessages", e);
            }
        }
        linkDescription = Emoji.replaceEmoji(linkDescription, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:17,代码来源:MessageObject.java

示例9: generateCaption

import android.text.util.Linkify; //导入依赖的package包/类
public void generateCaption() {
    if (caption != null) {
        return;
    }
    if (messageOwner.media != null && messageOwner.media.caption != null && messageOwner.media.caption.length() > 0) {
        caption = Emoji.replaceEmoji(messageOwner.media.caption, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
        if (containsUrls(caption)) {
            try {
                Linkify.addLinks((Spannable) caption, Linkify.WEB_URLS | Linkify.PHONE_NUMBERS);
            } catch (Exception e) {
                FileLog.e("tmessages", e);
            }
            addUsernamesAndHashtags(caption, true);
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:17,代码来源:MessageObject.java

示例10: formatMessages

import android.text.util.Linkify; //导入依赖的package包/类
private void formatMessages() {
    // Add actual minutes to string template.
    TextView textView1 = (TextView) findViewById(R.id.text_introduction_content);
    final long hours = TimeUnit.SECONDS.toMinutes(MyTileService.MAX_TIME_SEC);
    textView1.setText(getString(R.string.introduction_body, hours));

    // Linkify github link.
    TextView textview2 = (TextView) findViewById(R.id.text_opensource_body);
    LinkifyCompat.addLinks(textview2, Linkify.WEB_URLS);

    // Spanning color on textviews.
    applySpan((TextView) findViewById(R.id.text_install_body_1),
              R.id.text_install_body_1,
              "Step 1");

    applySpan((TextView) findViewById(R.id.text_install_body_2),
              R.id.text_install_body_2,
              "Step 2");

    applySpan((TextView) findViewById(R.id.text_install_body_3),
              R.id.text_install_body_3,
              "Step 3");

}
 
开发者ID:r3bl-alliance,项目名称:stay-awake-app,代码行数:25,代码来源:MainActivity.java

示例11: displayAboutDialog

import android.text.util.Linkify; //导入依赖的package包/类
private void displayAboutDialog() {
    final int paddingSizeDp = 5;
    final float scale = getResources().getDisplayMetrics().density;
    final int dpAsPixels = (int) (paddingSizeDp * scale + 0.5f);

    final TextView textView = new TextView(this);
    final SpannableString text = new SpannableString(getString(R.string.about_dialog_text));

    textView.setText(text);
    textView.setAutoLinkMask(RESULT_OK);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setPadding(dpAsPixels, dpAsPixels, dpAsPixels, dpAsPixels);

    Linkify.addLinks(text, Linkify.ALL);
    new AlertDialog.Builder(this)
            .setTitle(R.string.menu_about)
            .setCancelable(false)
            .setPositiveButton(android.R.string.ok, null)
            .setView(textView)
            .show();
}
 
开发者ID:xiaoyaoyou1212,项目名称:XSnow,代码行数:22,代码来源:MainActivity.java

示例12: initialize

import android.text.util.Linkify; //导入依赖的package包/类
@Override
protected void initialize(final Activity activity, Tab tab) {
    Resources resources = activity.getResources();
    mSuccessColor = colorToHexValue(ApiCompatibilityUtils.getColor(resources,
            R.color.physical_web_diags_success_color));
    mFailureColor = colorToHexValue(ApiCompatibilityUtils.getColor(resources,
            R.color.physical_web_diags_failure_color));
    mIndeterminateColor = colorToHexValue(ApiCompatibilityUtils.getColor(resources,
            R.color.physical_web_diags_indeterminate_color));

    LayoutInflater inflater = LayoutInflater.from(activity);
    mPageView = inflater.inflate(R.layout.physical_web_diagnostics, null);

    mLaunchButton = (Button) mPageView.findViewById(R.id.physical_web_launch);
    mLaunchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.startActivity(createListUrlsIntent());
        }
    });

    mDiagnosticsText = (TextView) mPageView.findViewById(R.id.physical_web_diagnostics_text);
    mDiagnosticsText.setAutoLinkMask(Linkify.WEB_URLS);
    mDiagnosticsText.setText(Html.fromHtml(createDiagnosticsReportHtml()));
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:26,代码来源:PhysicalWebDiagnosticsPage.java

示例13: linkifyUsers

import android.text.util.Linkify; //导入依赖的package包/类
private static void linkifyUsers(Spannable spannable, final Map<String, String> userMap) {
    Linkify.MatchFilter filter = new Linkify.MatchFilter() {
        @Override
        public final boolean acceptMatch(final CharSequence s, final int start, final int end) {
            String name = s.subSequence(start + 1, end).toString().trim();
            return userMap.containsKey(name);
        }
    };
    Linkify.TransformFilter transformFilter = new Linkify.TransformFilter() {
        @Override
        public String transformUrl(Matcher matcher, String value) {
            String userName = value.subSequence(1, value.length()).toString().trim();
            String userId = userMap.get(userName);
            return userId;
        }
    };

    Linkify.addLinks(spannable, PATTERN_AT, SCHEME_AT, filter, transformFilter);
}
 
开发者ID:betroy,项目名称:xifan,代码行数:20,代码来源:PatternUtils.java

示例14: onCreateDialog

import android.text.util.Linkify; //导入依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final TextView textView = new TextView(getActivity());
    final SpannableString spannableMsg = new SpannableString("See your real time car data at page " + Config.WWW_APP_URL + "/pages/index.html?account=TODO");

    Linkify.addLinks(spannableMsg, Linkify.WEB_URLS);
    textView.setText(spannableMsg);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setPadding(20,20,20,20);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Your Account")
            .setView(textView)
            .setPositiveButton(android.R.string.ok, null);

    return builder.create();
}
 
开发者ID:kocur,项目名称:Obd2-Tracker,代码行数:19,代码来源:GeneratedAccountIdDialog.java

示例15: generateLinkDescription

import android.text.util.Linkify; //导入依赖的package包/类
public void generateLinkDescription() {
    if (linkDescription != null) {
        return;
    }
    if (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageOwner.media.webpage instanceof TLRPC.TL_webPage && messageOwner.media.webpage.description != null) {
        linkDescription = Spannable.Factory.getInstance().newSpannable(messageOwner.media.webpage.description);
    } else if (messageOwner.media instanceof TLRPC.TL_messageMediaGame && messageOwner.media.game.description != null) {
        linkDescription = Spannable.Factory.getInstance().newSpannable(messageOwner.media.game.description);
    }
    if (linkDescription != null) {
        if (containsUrls(linkDescription)) {
            try {
                Linkify.addLinks((Spannable) linkDescription, Linkify.WEB_URLS);
            } catch (Exception e) {
                FileLog.e("tmessages", e);
            }
        }
        linkDescription = Emoji.replaceEmoji(linkDescription, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:21,代码来源:MessageObject.java


注:本文中的android.text.util.Linkify类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。