I have same info String like... String info1 ="yyy"; String info2 ="mmm";
Now I want to disply it in Html Format and bold As..
Our First Information:yyy Our Second Information:mmm
I have same info String like... String info1 ="yyy"; String info2 ="mmm";
Now I want to disply it in Html Format and bold As..
Our First Information:yyy Our Second Information:mmm
String info1 ="yyy"; String info2 ="mmm";
etmsg.setText(Html.fromHtml("First Info <b>"+info1+"</b>"+"<br/>Second Info <b>"+info2+"</b>"));
Just pointing out that a SpannableStringBuilder may be an interesting alternative if you're looking for a non-HTML-based solution. This way you could for example also use an inline HTML-styled link (URLSpan) to not execute the default ACTION_VIEW on the provided URL, but have it launch a new activity - or anything else you like.
String boldText = getString(R.string.bold_text);
String italicText = getString(R.string.italic_text);
String strikethroughText = getString(R.string.strikethrough_text);
String urlText = getString(R.string.url_text);
SpannableStringBuilder ssb = new SpannableStringBuilder();
ssb.append(boldText);
ssb.setSpan(new StyleSpan(Typeface.BOLD), ssb.length()-boldText.length(), ssb.length() , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.append(" ");
ssb.append(italicText);
ssb.setSpan(new StyleSpan(Typeface.ITALIC), ssb.length()-italicText.length(), ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.append(" ");
ssb.append(strikethroughText);
ssb.setSpan(new StrikethroughSpan(), ssb.length()-strikethroughText.length(), ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.append(" ");
ssb.append(urlText);
ssb.setSpan(new URLSpan("http://www.stackoverflow.com"), ssb.length()-urlText.length(), ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
TextView tv = (TextView) findViewById(R.id.spannable_text);
tv.setText(ssb);
Which will look as follows:
Other spans can be found as subclass of CharacterStyle. E.g. the TextAppearanceSpan allows you to do most of the above but then by using xml-declared styles. I've used it to create a Button with two lines of text with different styles (different text size and colour) applied to each line.