Why doesn't my text be bold when displaying on device screen

Posted by john123 on Stack Overflow See other posts from Stack Overflow or by john123
Published on 2012-12-12T10:56:25Z Indexed on 2012/12/12 11:03 UTC
Read the original article Hit count: 209

My string.xml:

<!--I try to bold my argument %s, like below:-->
<string name="hello">Hello to: <b>%s</b> !</string>

My layout main.xml:

<LinearLayout
   ...>

<TextView
     android:id="@+id/hello_txt"
     ...
     .../>

</LinearLayout>

My Fragment class:

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

  }
}

When I run my app on my device, I got "Hello to: Monday !" displaying on screen, but the "Monday" is not bold, but I used <b> in my string.xml. Why it is not bold??

© Stack Overflow or respective owner

Related posts about android

Related posts about android-layout