The Xamarin Android ForegroundColorSpan.ForegroundColor Property is readonly.
How can we then set this at runtime if we want to dynamically change the color of a span?
UPDATED
To provide more information, I'm trying to recreate the example given in Android documentation. The below code is in Java, but due to the read only nature of the span's color property in Xamarin Android, how can this code be recreated in Xamarin?
https://developer.android.com/guide/topics/text/spans
public class MainActivity extends AppCompatActivity {
private BulletPointSpan bulletSpan = new BulletPointSpan(Color.RED);
@Override
protected void onCreate(Bundle savedInstanceState) {
...
SpannableString spannable = new SpannableString("Text is spantastic");
// setting the span to the bulletSpan field
spannable.setSpan(bulletSpan, 0, 4, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
styledText.setText(spannable);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// change the color of our mutable span
bulletSpan.setColor(Color.GRAY);
// color won’t be changed until invalidate is called
styledText.invalidate();
}
});
}
}