Android Drawable Create getDrawableByName(Context ctx, String name)

Here you can find the source of getDrawableByName(Context ctx, String name)

Description

get Drawable By Name

Declaration

public static Bitmap getDrawableByName(Context ctx, String name) 

Method Source Code

//package com.java2s;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Main {
    public static Bitmap getDrawableByName(Context ctx, String name) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        Bitmap bitmap = BitmapFactory.decodeResource(
                ctx.getResources(),// w  ww .ja va 2  s. c om
                ctx.getResources().getIdentifier(name, "drawable",
                        ctx.getPackageName()), options);
        return bitmap;
    }
}

Related

  1. loadDrawable(final String imageUrl, final ImageView imageView, final ImageCallback imageCallback)
  2. getDrawableById(Context paramContext, String paramString)
  3. getDrawableFromUrl(String url)
  4. getPressedDrawable(int color)
  5. getDrawable(final Context context, final String packageName, final int resourceID)
  6. drawableToTransitionDrawable( Drawable drawable)
  7. createTempImageFile(Context context, Drawable drawable)
  8. loadImageFromUrl(String url)