Created
December 5, 2017 20:09
-
-
Save rdelrosario/d5d382b96f65310186a69c196199fdb7 to your computer and use it in GitHub Desktop.
Android - Formatted String
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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