Apply only the spans from src to dst specific by spans. - Android Graphics

Android examples for Graphics:Spannable

Description

Apply only the spans from src to dst specific by spans.

Demo Code


//package com.java2s;
import android.support.annotation.NonNull;
import android.text.Spannable;

import android.text.Spanned;

import java.util.Collection;

public class Main {
    /**//w ww  . ja v a2s. c o m
     * Apply only the spans from src to dst specific by spans.
     *
     * @see {@link android.text.TextUtils#copySpansFrom}
     */
    public static void copySpans(@NonNull Spanned src,
            @NonNull Spannable dst, @NonNull Collection<Object> spans) {
        for (Object span : spans) {
            int start = src.getSpanStart(span);
            int end = src.getSpanEnd(span);
            int flags = src.getSpanFlags(span);
            dst.setSpan(span, start, end, flags);
        }
    }
}

Related Tutorials