trim Char Sequence from Spanned - Android java.lang

Android examples for java.lang:String Strip

Description

trim Char Sequence from Spanned

Demo Code

import android.text.SpannableStringBuilder;
import android.text.Spanned;

public class Main{

    public static String trimCharSequence(final String text, final int size) {
        return text.length() > size ? text.substring(0, size) : text;
    }/*from w  w  w.  j a  va 2s .c  o  m*/
    public static Spanned trimCharSequence(final Spanned spanned,
            final int size) {
        return spanned.length() > size ? new SpannableStringBuilder(
                spanned, 0, size) : spanned;
    }

}

Related Tutorials