Share via


How to display bold text in Alert Dialog

Question

Friday, August 28, 2020 3:22 PM

I have created this code for displaying bold in AlertDialog but all the html code is ignored, do we know why?

``` public static ISpanned SetHtml(string html) { return HtmlCompat.FromHtml(html, HtmlCompat.FromHtmlModeLegacy); }

private void ShowUserGuideDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(Activity, Resource.Style.CommonAlertDialog); alert.SetTitle(GetString(Resource.String.InfoUserGuide)); alert.SetIcon(Resource.Mipmap.iclauncher); alert.SetMessage(SetHtml(GetString(Resource.String.Info_UserGuiderContent))); alert.SetPositiveButton(GetString(Android.Resource.String.Ok), (s, ex) => { }); alert.Show(); } ```

Right now <b> and \n tags are being ignored while if i do alert.SetMessage(GetString(Resource.String.Info_UserGuiderContent)); only <b> tags are ignored

All replies (1)

Friday, August 28, 2020 3:45 PM

Changed <b> </b> to &lt;b> &lt;/b> and \n to &lt;br/> and now it works.