當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。