Loading drawable from sd card

后端 未结 2 567
忘了有多久
忘了有多久 2020-12-17 02:32

I\'m trying to load a png image as a drawable from my device sd card. I use the following function but it doesn\'t work:

public Drawable getDrawable()
{
retu         


        
2条回答
  •  一整个雨季
    2020-12-17 02:44

    I am simple do like that

    public Drawable getDrawableFromPath(String filePath) {
        Bitmap bitmap = BitmapFactory.decodeFile(filePath);
        //Here you can make logic for decode bitmap for ignore oom error.
        return new BitmapDrawable(bitmap);
    }
    

提交回复
热议问题