KaliMa KaliMa - 1 year ago 72
Android Question

Display string with bold letters in Dialog message

Let's say I had this:

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
.setMessage("I want THIS word to be bold and the rest normal!")

Is there any way to have Android apply formatting or bold font to parts of the text string?

Answer Source

You can add a string to your strings.xml like this:

<string name="bold_message">I want <b>THIS</b> word to be bold and the rest normal!</string>

and then in your alert dialog just use setMessage(R.string.bold_message)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download