Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created December 5, 2017 20:09
Show Gist options
  • Save rdelrosario/d5d382b96f65310186a69c196199fdb7 to your computer and use it in GitHub Desktop.
Save rdelrosario/d5d382b96f65310186a69c196199fdb7 to your computer and use it in GitHub Desktop.
Android - Formatted String
void UpdateFormattedTitleText(Android.Widget.TextView titleTextView, FormattedString formattedString, string defaulTitle)
{
if (formattedString != null && formattedString.Spans.Count > 0)
{
titleTextView.TextFormatted = formattedString.ToAttributed(Font.Default, Xamarin.Forms.Color.Default, titleTextView);
}
else
{
//Update if not formatted text then update with normal title text
UpdateTitleText(titleTextView, defaulTitle);
}
}
void UpdateTitleText(Android.Widget.TextView titleTextView, string text)
{
if (!string.IsNullOrEmpty(text))
{
titleTextView.Text = text;
}
else
{
titleTextView.Text = string.Empty;
titleTextView.TextFormatted = new Java.Lang.String("");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment