8
<string-array name="myarray">    
<item>Apple</item> 
<item>Banana</item> 
<item>Grape</item>
<item>Melon</item>

if i want to add Underline the "Banana" what should I add?

adig
  • 115
  • 1
  • 3
  • 9

2 Answers2

20

use SpannableString by which you can do Underline, Strike, Highlight, Bold, Italic etc to the text

for Underline you have to use UnderlineSpan http://developer.android.com/reference/android/text/style/UnderlineSpan.html

 TextView textview = (TextView)findViewById(R.id.textview);
 SpannableString content = new SpannableString("Apple Banana Grape Melon");
 content.setSpan(new UnderlineSpan(), 6, 11, 0);
 textview.setText(content);

or simply by adding HTML tag to the resource string <string name="sample"> <u>your data</u></string>

Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
  • This string will I show the button text, so if the button is clicked it will display the button text "Apple", "Banana", "Grape" and appeared Underline the words "Banana" – adig Apr 13 '12 at 07:26
  • see updated answer, you have mold code according to requirement. I just shown you different way. – Mohammed Azharuddin Shaikh Apr 13 '12 at 07:34
3
<resource>
    <string name="your_string_here">This is an <u>underline</u>.</string>
</resources>
Abhi
  • 5,501
  • 17
  • 78
  • 133