[英]How to convert String to Uri which is taken from sqlite and set it in ImageView?
I was saving image Uri to SQLite as String which I picked from gallery and it was set as image to my ImageView. 我将图像Uri保存为SQLite作为String(从画廊中选取),并将其设置为ImageView的图像。 But from 2nd activity I'm taking the Image(Uri) as String and converting to Uri and setting to ImageView.
但是从第二个活动开始,我将Image(Uri)作为String并转换为Uri并设置为ImageView。
When I run the 2nd activity it is giving an error like 当我运行第二个活动时,出现了类似的错误
resolveUri failed on bad bitmap uri: content://com.miui.gallery.open/raw/06.jpg
The code is like. 代码就像。
String valueImage;
imageView.setImageURI(Uri.parse(valueImage));
Do I need to convert in another way? 我是否需要以其他方式转换?
Thank you. 谢谢。
You can use Glide . 您可以使用Glide 。 It's very easy and takes only one line.
这很容易,只需要一行。
String valueImage; // Get url fro SQLite
Glide
.With(this)
.Load(Uri.parse(valueImage))
.Apply(RequestOptions.CircleCropTransform()).Into(imageView);
The import statement is to put into the app module gradle file (app/build.gradle) import语句将放入app模块gradle文件(app / build.gradle)
implementation 'com.github.bumptech.glide:glide:4.9.0'
Hope it helps ! 希望能帮助到你 !
Try Glide for your requirement 根据您的要求尝试滑翔
Import glide using gradle
使用
gradle
导入滑行
implementation 'com.github.bumptech.glide:glide:4.8.0'
Then set image to imageview using this method 然后使用此方法将图像设置为imageview
Glide.with(context)
.load(Uri.fromFile(new File(valueImage)))
.into(imageView);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.