Reputation: 1617
Below are my codes, I'm trying to set Bold to my XML file using an XML Parser DOM. Can anyone please tell me how it is done? I just want my "Title :" to be bold.
textview.setText(textview.getText() + "<b>Title :</b> " //This line
+ getValue("title", eElement) + "\n" + "\n");
textview.setText(textview.getText() + "Description : "
+ getValue("description", eElement) + "\n" + "\n");
textview.setText(textview.getText() + "Link : "
+ getValue("link", eElement) + "\n" + "\n");
textview.setText(textview.getText() + "Date : "
+ getValue("date", eElement) + "\n" + "\n" + "\n"
+ "\n");
Upvotes: 0
Views: 4444
Reputation: 41
What you are missing is to tell the textview to convert from HTML.
so change it to textview.setText(Html.fromHtml(yourtext));
EDIT: If you have Problems with adding the resulting charSequence to your existing text, use:
Html.fromHtml(yourtext).toString()
You cannot concatinate it simply as you did it, because Html.fromHtml() returns a charSequence, not a String
Setting the style in the layout file will result in ALL the text being bold, italic, wahtsoever
Upvotes: 2
Reputation: 1632
You can do that directly in the textView
tag
Do this:
android:textStyle="bold"
Upvotes: 3
Reputation: 1500
use this ,
textView.setTypeface(null, Typeface.BOLD_ITALIC); or
textView.setTypeface(null, Typeface.BOLD);
using html,
tetview.setText(Html.fromHtml(somestring));
Upvotes: 3