Decode HTML entities in android

前端 未结 5 2020
臣服心动
臣服心动 2020-11-28 06:38

I need to decode HTML entities, e.g. from ö to ö, and & to &.

URLEncoder.decode(str) does not do the job (convert from % notat

5条回答
  •  天命终不由人
    2020-11-28 06:50

    Html.fromHtml(String html) is deprecated after API v24 so this is the correct way to do it

      if (Build.VERSION.SDK_INT >= 24)
      {
           textView.setText(Html.fromHtml(htmlString , Html.FROM_HTML_MODE_LEGACY)));  
      }
      else
      {
           textView.setText(Html.fromHtml(htmlString));
      }
    

提交回复
热议问题