get Drawable By Id - Android Graphics

Android examples for Graphics:Drawable Read

Description

get Drawable By Id

Demo Code


//package com.java2s;

import android.content.Context;

import android.graphics.drawable.Drawable;

public class Main {

    @SuppressWarnings("deprecation")
    public static Drawable getDrawableById(Context context, int resId) {
        if (context == null) {
            return null;
        }//from  w  ww  .  j a  v a2  s  .  c o  m

        return context.getResources().getDrawable(resId);
    }
}

Related Tutorials