get Drawable From Icon - Android Graphics

Android examples for Graphics:Drawable Operation

Description

get Drawable From Icon

Demo Code


//package com.java2s;
import android.app.Activity;

import android.graphics.drawable.Drawable;
import android.os.Build;

public class Main {
    public static Drawable getDrawableFromIcon(Activity activity, int iconId) {
        Drawable drawable = null;/* w  w  w  .j  ava  2  s  .c o m*/
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            drawable = activity.getResources().getDrawable(iconId,
                    activity.getTheme());
        } else {
            drawable = activity.getResources().getDrawable(iconId);
        }
        return drawable;
    }
}

Related Tutorials