get Drawables from ID - Android Graphics

Android examples for Graphics:Drawable Read

Description

get Drawables from ID

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;

public class Main {
    /**//from w  w  w  .  j a  v  a  2 s.  c  o m
     * 
     * @param context
     * @param id
     * @return
     */
    public static Drawable getDrawables(Context context, int id) {
        Drawable drawable = getResources(context).getDrawable(id);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(),
                drawable.getMinimumHeight());

        return drawable;
    }

    /**
     * 
     * @Title: getResource 
     * @Description: TODO 
     * @param context
     * @return Resources 
     */
    public static Resources getResources(Context context) {
        return context.getResources();
    }
}

Related Tutorials