color Remote Drawable - Android Graphics

Android examples for Graphics:Drawable

Description

color Remote Drawable

Demo Code


//package com.java2s;
import android.graphics.PorterDuff;
import android.widget.RemoteViews;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    public static void colorRemoteDrawable(RemoteViews cellView,
            int resource, int color) {
        try {/* w  w w .j  av  a2  s. c o  m*/
            Class c = Class.forName("android.widget.RemoteViews");
            Method m = c.getMethod("setDrawableParameters", int.class,
                    boolean.class, int.class, int.class,
                    PorterDuff.Mode.class, int.class);
            m.invoke(cellView, resource, true, -1, color,
                    PorterDuff.Mode.MULTIPLY, -1);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials