lundi 30 mars 2015

Android formatting xml string loses its html tags

I have a xml string below that contains html tags such as Bold and a hyperlink href.



<string name"example"><b>%1$s</b> has been added to your clipboard and is valid until <b>%2$s</b><a href="http://www.google.com">Please see our +T\'s and C\'s+ </a> </string>


when i format the string to dynamically add some values it removes the bolded text and href I defined.


code below:



SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yy");
Date date = new Date(text.getValidTo());
String text = String.format(getString(R.string_dialog_text), text.getCode(), simpleDateFormat.format(date), "£30");


I then apply it to a alert dialog



AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setNeutralButton(R.string.ok, onClickListener);
builder.setTitle(title);
builder.setMessage(text);


this worked fine if i dont format the text and directly use the string resource


Aucun commentaire:

Enregistrer un commentaire