I have a spanned
text that I need to cast to Spannable
.
Thats what I try to do in my code:
Spannable buffer = (Spannable) text;
This code is giving me a "can't cast Spannable to Spanned".
Is it possible? if so how?
Thanks!
Convert a spanned to spannable
You will surely get Class cast exception, because the text refers to Spanned which comes before in hierarchy to Spannable.
So, try getting the string of the text and then create a Spannable or SpannableString object.
Spannable buffer=new SpannableString(text);
© 2022 - 2024 — McMap. All rights reserved.