get Drawable By Name from Asset - Android App

Android examples for App:Assets Image

Description

get Drawable By Name from Asset

Demo Code


//package com.java2s;
import android.content.res.AssetManager;

import android.graphics.drawable.Drawable;

import java.io.IOException;

public class Main {
    public static String MainPath = "smsfaces";

    public static Drawable getDrawableByName(AssetManager mgr,
            String folder, String filename) {
        try {//www. j  a  va2 s.co  m
            Drawable d = Drawable.createFromStream(
                    mgr.open(MainPath + "/" + folder + "/" + filename),
                    null);
            return d;
        } catch (IOException e) {
            return null;
        }
    }
}

Related Tutorials