我的string.xml:
<!--I try to bold my argument %s, like below:-->
<string name="hello">Hello to: <b>%s</b> !</string>
我的布局main.xml:
<LinearLayout
...>
<TextView
android:id="@+id/hello_txt"
...
.../>
</LinearLayout>
我的片段类:
public class MyFragment extends Fragment{
TextView helloTxt;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
helloTxt = (TextView) findViewById(R.id.hello_txt);
}
@Override
public void onStart() {
super.onStart();
//pass "Monday" as the argument to my string
helloTxt.setText(String.format(getString(R.string.hello), "Monday"));
}
}
当我在我的设备上运行我的应用程序时,屏幕上显示“ Hello to: Monday! ”,但“ Monday ”不是粗体,但我<b>
在我的string.xml中使用了。为什么不加粗??