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


Java Html.fromHtml方法代码示例

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


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

示例1: getFormattedTitle

import android.text.Html; //导入方法依赖的package包/类
@Override
public CharSequence getFormattedTitle(Context context, int viewMode) {
    String ret = null;
    if (mShowTitle != null) {
        // Build the first part of the title: "show name + SxEy"
        ret = String.format(TITLE_FORMAT, mShowTitle, mSeasonNumber, mEpisodeNumber);

        if (viewMode == VideoUtils.VIEW_MODE_LIST) {
            // Append the episode name in italics: " <<episode name>>"
            String episodeNameFormat = context.getString(R.string.quotation_format);
            String episodeName = String.format(episodeNameFormat, mEpisodeTitle);
            return Html.fromHtml(ret + " <i>" + episodeName + "</i>");
        }
    }
    return ret;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:17,代码来源:EpisodeInfo.java

示例2: setErrorHint

import android.text.Html; //导入方法依赖的package包/类
/**
 * Set the hint for an EditText to the specified string on error
 *
 * @param editText edit widget
 * @param resId    string resource
 */
private void setErrorHint(EditText editText, @StringRes int resId)
{
    String html = "<font color='#ff0000'>" + getResources().getText(resId) + "</font>";
    CharSequence hint;
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N)
    {
        hint = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
    }
    else
    {
        //noinspection deprecation
        hint = Html.fromHtml(html);
    }
    editText.setHint(hint);
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:22,代码来源:AuthenticatorActivity.java

示例3: onPostsLoadedEvent

import android.text.Html; //导入方法依赖的package包/类
@Subscribe
public void onPostsLoadedEvent(PostsLoadedEvent event) {
    // this exists to let animation run to completion because posts are loaded
    // twice on launch: once cached data, and once from the network
    if (mPosts.equals(event.posts)) {
        return;
    }
    mPosts.clear();
    mPosts.addAll(event.posts);
    if (mPosts.size() >= event.postsFetchLimit) {
        CharSequence message = Html.fromHtml(getString(R.string.post_limit_exceeded,
                getString(R.string.app_name), event.postsFetchLimit,
                "https://github.com/vickychijwani/quill/issues/81"));
        mPostAdapter.showFooter(message);
    } else {
        mPostAdapter.hideFooter();
    }
    mPostAdapter.notifyDataSetChanged();
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:20,代码来源:PostListActivity.java

示例4: fromHtml

import android.text.Html; //导入方法依赖的package包/类
public static Spanned fromHtml(String html){
    Spanned result;
    if (android.os.Build.VERSION.SDK_INT >= 24) {
       result = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
    } else {
       result = Html.fromHtml(html);
    }
    return result;
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:10,代码来源:TextBuilder.java

示例5: fromHtml

import android.text.Html; //导入方法依赖的package包/类
/**
 * Helper class to handle deprecated method.
 * Source: http://stackoverflow.com/questions/37904739/html-fromhtml-deprecated-in-android-n
 * @param html html string
 * @return Spanned
 */
@SuppressWarnings("deprecation")
public static Spanned fromHtml(String html){
    Spanned result;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        result = Html.fromHtml(html,Html.FROM_HTML_MODE_LEGACY);
    } else {
        result = Html.fromHtml(html);
    }
    return result;
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:17,代码来源:ActivityUtils.java

示例6: getView

import android.text.Html; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null)
        convertView = LayoutInflater.from(getContext()).inflate(resource, null);

    ContactItem contact = getItem(position);
    if (contact != null) {
        String html = "<b>" + contact.name + "</b> " + contact.number;
        Spanned newText;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
            newText = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
        else
            newText = Html.fromHtml(html);

        CheckedTextView textView = (CheckedTextView) convertView;
        textView.setText(newText);
        textView.setChecked(contact.checked);
        textView.jumpDrawablesToCurrentState(); // (!!!) Ferma l'animazione dovuta a setChecked, terribile quando vengono riciclate le view
    }

    return convertView;
}
 
开发者ID:gvinciguerra,项目名称:custode,代码行数:23,代码来源:ContactsAdapter.java

示例7: onCreateDialog

import android.text.Html; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //noinspection unchecked
    final ArrayList<PlaylistSong> songs = getArguments().getParcelableArrayList("songs");
    int title;
    CharSequence content;
    if (songs.size() > 1) {
        title = R.string.remove_songs_from_playlist_title;
        content = Html.fromHtml(getString(R.string.remove_x_songs_from_playlist, songs.size()));
    } else {
        title = R.string.remove_song_from_playlist_title;
        content = Html.fromHtml(getString(R.string.remove_song_x_from_playlist, songs.get(0).title));
    }
    return new MaterialDialog.Builder(getActivity())
            .title(title)
            .content(content)
            .positiveText(R.string.remove_action)
            .negativeText(android.R.string.cancel)
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    if (getActivity() == null)
                        return;
                    PlaylistsUtil.removeFromPlaylist(getActivity(), songs);
                }
            })
            .build();
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:30,代码来源:RemoveFromPlaylistDialog.java

示例8: fromHtml

import android.text.Html; //导入方法依赖的package包/类
public static Spanned fromHtml(String text) {
    if(Utils.hasNougat()){
        return Html.fromHtml(text, 0);
    } else {
        return Html.fromHtml(text);
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:8,代码来源:Utils.java

示例9: formatText

import android.text.Html; //导入方法依赖的package包/类
protected Spanned formatText(String text) {
    if (text == null) {
        return null;
    }

    if (text.matches(".*\\de[-" + Constants.MINUS + "]?\\d.*")) {
        text = text.replace("e", Constants.MUL + "10^");
    }
    return Html.fromHtml(
            mEquationFormatter.insertSupScripts(
                    mEquationFormatter.addComas(mSolver, text)));
}
 
开发者ID:tranleduy2000,项目名称:floating_calc,代码行数:13,代码来源:FloatingHistoryAdapter.java

示例10: fromHtml

import android.text.Html; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public Spanned fromHtml(String source) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
    } else {
        return Html.fromHtml(source);
    }
}
 
开发者ID:malah-code,项目名称:Open-Quran-Radio,代码行数:9,代码来源:PlayerActivityFragment.java

示例11: checkPermission

import android.text.Html; //导入方法依赖的package包/类
public void checkPermission(CheckPermListener listener, int resString, String... mPerms) {
    mListener = listener;
    if (EasyPermissions.hasPermissions(this, mPerms)) {
        if (mListener != null)
            mListener.grantPermission();
    } else {
        CharSequence text= Html.fromHtml("<font color=\"#000000\">"+getString(resString)+"</font>");
        EasyPermissions.requestPermissions(this, text,
                RC_PERM, mPerms);
    }
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:12,代码来源:PermissionActivity.java

示例12: fromHtml

import android.text.Html; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static Spanned fromHtml(String source) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
    } else {
        return Html.fromHtml(source);
    }
}
 
开发者ID:adriankeenan,项目名称:uob-timetable-android,代码行数:10,代码来源:AndroidUtilities.java

示例13: onCreate

import android.text.Html; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_terms);

    String htmlAsString = getString(R.string.privacy_policy_html);
    Spanned htmlAsSpanned;

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        htmlAsSpanned = Html.fromHtml(htmlAsString,Html.FROM_HTML_MODE_LEGACY);
    } else {
        htmlAsSpanned = Html.fromHtml(htmlAsString);
    }

    // set the html content on a TextView
    TextView textView = (TextView) findViewById(R.id.textView_privacy_policy);
    textView.setText(htmlAsSpanned);

    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    Button ok = (Button) findViewById(R.id.privacy_policy_button);

    ok.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            prefs.edit().putBoolean("terms_shown", true).apply();
            finish();
        }
    });


}
 
开发者ID:xRahul,项目名称:FicsaveMiddleware,代码行数:33,代码来源:TermsActivity.java

示例14: fromHtml

import android.text.Html; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static Spanned fromHtml(String html) {
    Spanned result;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        result = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
    } else {
        result = Html.fromHtml(html);
    }
    return result;
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:11,代码来源:DetailActivityFragment.java

示例15: decode

import android.text.Html; //导入方法依赖的package包/类
@Override
protected SubripSubtitle decode(byte[] bytes, int length, boolean reset) {
  ArrayList<Cue> cues = new ArrayList<>();
  LongArray cueTimesUs = new LongArray();
  ParsableByteArray subripData = new ParsableByteArray(bytes, length);
  String currentLine;

  while ((currentLine = subripData.readLine()) != null) {
    if (currentLine.length() == 0) {
      // Skip blank lines.
      continue;
    }

    // Parse the index line as a sanity check.
    try {
      Integer.parseInt(currentLine);
    } catch (NumberFormatException e) {
      Log.w(TAG, "Skipping invalid index: " + currentLine);
      continue;
    }

    // Read and parse the timing line.
    boolean haveEndTimecode = false;
    currentLine = subripData.readLine();
    Matcher matcher = SUBRIP_TIMING_LINE.matcher(currentLine);
    if (matcher.matches()) {
      cueTimesUs.add(parseTimecode(matcher, 1));
      if (!TextUtils.isEmpty(matcher.group(6))) {
        haveEndTimecode = true;
        cueTimesUs.add(parseTimecode(matcher, 6));
      }
    } else {
      Log.w(TAG, "Skipping invalid timing: " + currentLine);
      continue;
    }

    // Read and parse the text.
    textBuilder.setLength(0);
    while (!TextUtils.isEmpty(currentLine = subripData.readLine())) {
      if (textBuilder.length() > 0) {
        textBuilder.append("<br>");
      }
      textBuilder.append(currentLine.trim());
    }

    Spanned text = Html.fromHtml(textBuilder.toString());
    cues.add(new Cue(text));
    if (haveEndTimecode) {
      cues.add(null);
    }
  }

  Cue[] cuesArray = new Cue[cues.size()];
  cues.toArray(cuesArray);
  long[] cueTimesUsArray = cueTimesUs.toArray();
  return new SubripSubtitle(cuesArray, cueTimesUsArray);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:58,代码来源:SubripDecoder.java


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