Search code examples
androidarraystextviewfont-face

change font type of item in string array


I have a string array in my strings.xml and i would like to change the font type to one which I have in my assets folder. Below is a sample of my code in strings.xml:

<string-array name="htmlstrings">
<item>BBQ Steak  marinated BBQ Steak  &lt;b&gt;Regular&lt;b&gt;   Medium    Large  sh 500   sh 700  sh 900</item>
</string-array>

And my Java code for retriving the text is below:

String[] htmlstrings = getResources().getStringArray(R.array.htmlstrings);
description.setText(Html.fromHtml(htmlstrings[x]));

From there I don't know how to apply a different font type to the text inside the item. Some help please.


Solution

  • this is the common answer in stackoverflow.. search before ask question..

    here is your answer

    Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/verdana.ttf");  
    description.setTypeface(tf,Typeface.BOLD);