Propriété de Albiri Sigue
customer 27921 at Fri Mar 11 19:19:45 +0100 2011
202 L’art du développement Android
3. Produisez le résultat du formatage, en vous assurant de protéger les valeurs de chaînes
que vous substituez, au cas où elles contiendraient des chevrons ou des esperluettes :
String.format(getString(R.string.format_style),
TextUtils.htmlEncode(nom));
4. Convertissez le HTML encodé en objet Spanned grâce à Html.fromHtml().
uneTextView.setText(Html.fromHtml(resultatDeStringFormat));
Pour voir tout ceci en action, examinons le fichier de description du projet Resources/
Strings :

android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
Précédent

- 217/391

Suivant