我有以下形式的文件路径字符串E:\ ... \ XXX.JPG 如何从它创建一个可绘制的?
I have a file path String of the form "e:\...\xxx.jpg" How do I create a drawable from it?
您可以从这样的路径字符串创建一个可绘制或位图:
You can create a Drawable or Bitmap from a string path like this:
String pathName = "/path/to/file/xxx.jpg";
Drawable d = Drawable.createFromPath(pathName);
对于一个位图:
For a Bitmap:
String pathName = "/path/to/file/xxx.jpg";
bitmap b = BitmapFactory.decodeFile(pathName);