get Content Color SpannableString - Android Graphics

Android examples for Graphics:Spannable Color

Description

get Content Color SpannableString

Demo Code


//package com.java2s;
import android.content.Context;

import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;

public class Main {
    public static SpannableString getContentColor(Context context,
            String quoto, String message) {
        SpannableString sp = new SpannableString(quoto + message);
        sp.setSpan(//w w w .ja  v a2s  .c  om
                new ForegroundColorSpan(context.getResources().getColor(
                        android.R.color.transparent)), 0, quoto.length(),
                Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
        sp.setSpan(
                new ForegroundColorSpan(context.getResources().getColor(
                        android.R.color.transparent)), quoto.length(),
                sp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        return sp;
    }

    public static SpannableString getContentColor(Context context,
            int quotoId, int messageId) {
        return getContentColor(context, context.getString(quotoId),
                context.getString(messageId));
    }

    public static SpannableString getContentColor(Context context,
            int quotoId, String message) {
        return getContentColor(context, context.getString(quotoId), message);
    }
}

Related Tutorials