Trying to format my output (in a TextView) using HTML. I need to get the text HTML-formating back from the old output, and add the new text one line above it.
String previous = Html.toHtml((Spanned) chatOutput.getText());
chatOutput.setText(Html.fromHtml(message + "<br>" + previous));
This compiles but gives a java.lang.ClassCastException: java.lang.String on runtime at the toHtml() method. I saw several people that suggested that the toHtml() method could be used that way, but maybe I'm missing something.
Figured it out. Changing the cast to Spannable and have used the setText method with the BufferType.SPANNABLE solved the orginal problem.
Then a follow-up issue occurred, weird line braking in the textview. Turned out that html-paragraph code was added somewhere in this process, ugly solution below when manually deleting it. The solution got even more tacky when I realised that additonal parameters in the paragraph-statement was added by a device with API 18, compared my testing device with API 8.