0
 String  _body = "sq Home : "+HomeScreen.edt_sqft_home.getText().toString() +"\n"
                        +"Age of Home years : "+HomeScreen.edt_age.getText().toString() +"\n"
                        +"Additional service : "+HomeScreen.output +"\n\n"
                        +"Street Name : "+HomeScreen.edt_streetname.getText().toString() +"\n"
                        +"City : "+HomeScreen.edt_city.getText().toString() +"\n"
                        +"State : "+HomeScreen.edt_state.getText().toString();

hiii i want to bold text which is in "". like "Sq Home","Age of Home Years". how is it posible?? plz help me

Google
  • 2,183
  • 3
  • 27
  • 48

2 Answers2

0
String source = "This is example text";
Spannable out = new SpannedString(source);
StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
StyleSpan boldSpan2 = new StyleSpan(Typeface.BOLD);
out.setSpan(boldSpan, 1, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
out.setSpan(boldSpan2, 9, 12, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Android
  • 2,383
  • 1
  • 26
  • 44
0

If your string is going to be shown in a TextView you can use HTML tags. In your case you only have to do this:

String _body = "<b>sq Home</b>: " + HomeScreen.edt_sqft_home.getText().toString() + "<br/>"
       + "<b>Age of Home years</b>: " + HomeScreen.edt_age.getText().toString() + "<br/>"
       + "<b>Additional service</b>: " + HomeScreen.output + "<br/><br/>"
       + "<b>Street Name</b>: " + HomeScreen.edt_streetname.getText().toString() + "<br/>"
       + "<b>City</b>: " + HomeScreen.edt_city.getText().toString() + "<br/>"
       + "<b>State</b>: " + HomeScreen.edt_state.getText().toString();

TextView yourTextView = findViewById(R.id.yourTextViewId);
yourTextView.setText(Html.fromHtml(_body));

Where yourTextView is the view of your Activity that displays the HTML string.

Mark Murphy wrote a post with the HTML tags supported by TextView.

José Juan Sánchez
  • 14,429
  • 1
  • 12
  • 7