0

This is not a duplicate of String array text formatting.I have viewed the answers of that question but are not applicable to mine.Below is my code:

description = (TextView)findViewById(R.id.description);

String [] item = {"BBQ Steak \n \n marinated BBQ Steak \n \n Regular Medium Large \n \n sh 500  sh 700  sh 900","Chicken BBQ bacon \n \n BBQ Chicken,Bacon,Sweet Corn,Onion \n \n Regular Medium    Large \n \n sh 500      sh 700  sh 900 ","Chicken and Mushroom \n \n chicken,mushroom \n \n Regular Medium  Large \n \n sh500   sh700   sh900","Chicken tikka \n \n marinated tikka chicken, green pepper, onion \n \n Regular Medium   Large  \n \n sh 500 sh 700  sh 900","Stack it up(large) \n \n Double stack ANY LARGE PIZZA \n \n chicken,mushroom,creamy,tomato mayo,mozzarella cheese \n \n sh 150 extra "}

description.setText(item[x]);

I used this array to store the description of particular pizzas which will be displayed when the user selects it.The pizzas are stored in a list item. However i would like to apply formatting styles to the information in the array such as bold on words like Regular but the word Regular is not used on all pizza descriptions.The use of Spannable String is difficult because I have a large amount of text.And I would also like to use different font styles.But mostly bold and underline styling.Any help will be highly appreciated.

Community
  • 1
  • 1
lorrainemutheu
  • 115
  • 1
  • 17
  • 1
    You can use HTML inside a TextView. Then simply pass the text by using `HTML.fromHtml()`. –  Jun 12 '16 at 17:26
  • @LonnieZamora I tried adding html tags such as Regular inside the string array then i added `description.setText(Html.fromHtml(item[x]));` but the tags appear when I run my application and the text is not bold – lorrainemutheu Jun 13 '16 at 15:51
  • Try `description.setText(Html.fromHtml("Regular.
    Bold."));`
    –  Jun 13 '16 at 15:55
  • `` is a supported tag, as clearly indicated [here](https://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html) –  Jun 13 '16 at 15:57

0 Answers0