2017-09-25 11 views
3

j'ai données JSON comme celui-cichaîne HTML n'est pas le rendu dans 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 rendu cette chaîne de notification Textview mais sa ne fonctionne pas.

c'est ce que j'ai essayé

Spanned 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);  
     } 

j'ai essayé aussi ce library:

Spanned fromHtml = HtmlCompat.fromHtml(context, notifications.getTitle(), 0); 
     holder.txtTitle.setMovementMethod(LinkMovementMethod.getInstance()); 
     holder.txtTitle.setText(fromHtml); 

mais rien de tout cela est le travail.

ce que je reçois en sortie:

enter image description here

et ce que je pense

enter image description here

+0

Avez-vous essayé ce https://stackoverflow.co m/questions/42389878/android-app-pas-rendu-html-tags-très-bien – Ankita

Répondre

1

Essayez modifing la chaîne de notification comme ceci:

{ 
"user_id": "27", 
"notification": "<a>There is package wiating for you to pick from <font color='blue'> #majuraget, surat</font> to <font color='blue'> #pal, surat</font> </a>" 
} 
+0

Merci .. son travaillé .. de sorte que les styles ne sont pas rendu sur le côté androïde .. seul attribut fait. –

+0

De rien. Je suis content d'avoir aidé :) – Laura