Android Context Get loadImageFromAsset(Context context, String id)

Here you can find the source of loadImageFromAsset(Context context, String id)

Description

load Image From Asset

Declaration

static public Drawable loadImageFromAsset(Context context, String id) 

Method Source Code

//package com.java2s;

import java.io.IOException;
import java.io.InputStream;

import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;

public class Main {
    static public Drawable loadImageFromAsset(Context context, String id) {

        try {//from   www.  j  a v a2  s .  co  m
            Resources resources = context.getResources();
            AssetManager am = resources.getAssets();
            InputStream ims = am.open(id + ".png");
            Drawable d = Drawable.createFromStream(ims, null);
            return d;
        } catch (IOException ex) {
            return null;
        }
    }
}

Related

  1. getBoolean(ContentValues alarm, String key)
  2. findOne(Context context, Uri uri)
  3. getCurrentTimeString(Context aContext, long aDate)
  4. getCurrentTimeString(Context context)
  5. readRaw(Context ctx, int res_id)
  6. hasTelephony(@Nonnull Context context)
  7. getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs)
  8. getPath(final Context context, final Uri uri)
  9. cachedJson(Context context, URI uri)