Java Code Examples for android.text.TextUtils.expandTemplate()

The following are Jave code examples for showing how to use expandTemplate() of the android.text.TextUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: chromium-for-android-56-debug-video   File: DuplicateDownloadInfoBar.java   Source Code and License Vote up 5 votes
/**
 * Helper method to get the text to be displayed on the infobar.
 * @param template Message template.
 * @param fileName Name of the file.
 * @param clickableSpan Action to perform when clicking on the file name.
 * @return message to be displayed on the infobar.
 */
private CharSequence getMessageText(final String template, final String fileName,
        final ClickableSpan clickableSpan) {
    final SpannableString formattedFilePath = new SpannableString(fileName);
    formattedFilePath.setSpan(new StyleSpan(Typeface.BOLD), 0, fileName.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    formattedFilePath.setSpan(clickableSpan, 0, fileName.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return TextUtils.expandTemplate(template, formattedFilePath);
}