Java tutorial
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import android.content.Context; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; public class Main { public static Drawable getAsssetDrawableByName(Context context, String name) { try { InputStream is = context.getAssets().open(name); return new BitmapDrawable(context.getResources(), BitmapFactory.decodeStream(is)); } catch (IOException e) { e.printStackTrace(); } return new ColorDrawable(Color.TRANSPARENT); } }