Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.RuntimeException: PARAGRAPH span must start at paragraph boundary (46 follows )

I am getting the below error While trying to Render the Text in the Text view

java.lang.RuntimeException: PARAGRAPH span must start at paragraph boundary (46 follows  )
                                                                   at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:161)
                                                                   at android.text.SpannableStringInternal.copySpans(SpannableStringInternal.java:67)
                                                                   at android.text.SpannableStringInternal.<init>(SpannableStringInternal.java:42)
                                                                   at android.text.SpannedString.<init>(SpannedString.java:30)
                                                                   at android.text.method.ReplacementTransformationMethod.getTransformation(ReplacementTransformationMethod.java:83)
                                                                   at android.widget.TextView.setText(TextView.java:4436)
                                                                   at android.widget.TextView.setText(TextView.java:4332)
                                                                   at android.widget.TextView.setText(TextView.java:4307)

I am calling like

myAsyncTask().execute(source, listDrawable, textView.getContext());
                    return listDrawable;
                }
            }, new MyTagHandler());
      textView.setText(htmlText);

Can anyone Help me in this to sort the above issue

like image 594
Anbu Avatar asked Oct 13 '16 10:10

Anbu


1 Answers

You're probably using the function Html.fromHtml(String source), which has been changed for Android SDK API >= 24 (Anrdroid 7.0), to get your Spannable for textView.setText(htmlText), so the resulting Spannable now differs a bit. Because of that, it won't fit to old deprecated functions/attributes anymore.

Therefore, you have three options to solve your problem:

  • (EDIT:) Probably the easiest solution: If you are using the android attribute android:singleLine=true in your list element use android:maxLines="1" instead.
  • Basically, you have to take care of your Spannables and their bounderies, especially if you're creating your Spannables by yourself.
  • Use only supported HTML tags, which can be read out directly from the source code (here).
  • You can also use the function loadDataWithBaseURL(...) to resolve your problem, but then you have to use a webview, which could be a big overload for a list element.
like image 124
mathew11 Avatar answered Oct 15 '22 01:10

mathew11