I am trying to get All Spans applied to text as below;
public String getTextWithTags(Editable e)
{
StyleSpan[] ss = e.getSpans(0,e.length(),StyleSpan.class);
ss[0].getSpanStart <--- ? This is the problem, no such function
return "";
}
But there is no index find function to replace tags to store them on database so i can retrieve all spans back when i reopen text. How can i get all span positions from editable object?
StyleSpan[] ss = e.getSpans(0,e.length(),StyleSpan.class);
for(StyleSpan span : ss){
int start = e.getSpanStart(span);
int end = e.getSpanEnd(span);
}
If u want to find Span start/end index, you can use this(example for a single RelativeSizeSpan
) -
val sb = text as SpannableStringBuilder
val firstSpan = getSpans(0, length, RelativeSizeSpan::class.java).first()
val start = (sb as Spanned).getSpanStart(firstSpan)
val end = (sb as Spanned).getSpanEnd(firstSpan)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With