Convert a spanned to spannable
Asked Answered
D

1

7

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!

Dufour answered 2/7, 2013 at 7:18 Comment(0)
P
8

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);
Principle answered 2/7, 2013 at 7:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.