This code always returns null

String path = "file:///android_asset/image.png";
Drawable d = null;
try {
     d = Drawable.createFromStream(ContextHolder.getActivity().getAssets().open(path), null);
} catch(Exception e) {

}
有帮助吗?

解决方案

The path is wrong

String path = "image.png";

其他提示

Drawable d = Drawable.createFromStream(getAssets().open("image.png"), null);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top