Ich habe ein json Daten wie dieseHTML-String rendert nicht in Textview
{
"user_id": "27",
"notification": "<a>There is package wiating for you to pick from <font style="color: blue;"> #Surat</font> to <font style = "color: blue;"> #Adajan, Surat, Gujarat, India</font> </a>",
},
{
"user_id": "27",
"notification": "<a>There is package wiating for you to pick from <font style="color: blue;"> #majuraget, surat</font> to <font style = "color: blue;"> #pal, surat</font> </a>",
},
{
"user_id": "27",
"notification": "<a>There is package wiating for you to pick from <font style="color: blue;"> #majuraget, surat</font> to <font style = "color: blue;"> #pal, surat</font> </a>",
},
{
"user_id": "27",
"notification": "<a>There is package wiating for you to pick from <font style="color: blue;"> #majuraget, surat</font> to <font style = "color: blue;"> #pal, surat</font> </a>",
}
i m Rendering diese Benachrichtigung Zeichenfolge in Textview, aber es funktioniert nicht.
das, was ich
versucht istSpanned value = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
value = Html.fromHtml(notifications.getTitle(), Html.FROM_HTML_MODE_COMPACT);
holder.txtTitle.setMovementMethod(LinkMovementMethod.getInstance());
holder.txtTitle.setText(value);
}else {
value = Html.fromHtml(notifications.getTitle());
holder.txtTitle.setMovementMethod(LinkMovementMethod.getInstance());
holder.txtTitle.setText(value);
}
Ich habe versucht, auch diese library:
Spanned fromHtml = HtmlCompat.fromHtml(context, notifications.getTitle(), 0);
holder.txtTitle.setMovementMethod(LinkMovementMethod.getInstance());
holder.txtTitle.setText(fromHtml);
aber nichts davon ist die Arbeit.
das ist, was ich als Ausgabe erhalten:
und das ist, was ich
Hast du dieses https://stackoverflow.co versucht m/questions/42389878/android-app-nicht-rendering-html-tags-very-well – Ankita