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 我想将“”中的文本加粗。比如“Sq Home”、“Age of Home Years”。怎么可能?请帮帮我

4

2 回答 2

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);
于 2013-04-04T10:26:51.727 回答
0

如果您的字符串将显示在 TextView 中,您可以使用 HTML 标记。在你的情况下,你只需要这样做:

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));

yourTextView显示 HTML 字符串的 Activity 视图在哪里。

Mark Murphy用 TextView 支持的 HTML 标签写了一篇文章。

于 2013-04-04T14:56:44.947 回答