【问题标题】:How can I retrieve an image using shared presences and show it in an image view in Android studio?如何使用共享状态检索图像并将其显示在 Android Studio 的图像视图中?
【发布时间】:2019-11-30 16:26:58
【问题描述】:

我正在尝试在我的活动的图像视图中设置图像,但我不知道代码是什么。

我知道怎么做,但使用此代码将文本设置为文本视图

TextViewUser.setText( sharedaPrefManager.getInstance(this, ).get Username ().

我需要怎么做,但为了一张图片。

我正在使用 volley 并且已经获得了图像,但我不知道如何将其放入图像视图中。

提前致谢

【问题讨论】:

标签: android mysql android-volley


【解决方案1】:

一旦你得到图像 URL,如下所示将其加载到 ImageView 中

试试毕加索图书馆

添加到 build.gradle

implementation 'com.squareup.picasso:picasso:2.71828'

然后

String imageUrl = "https://example.com/someimage.png"

Picasso.get().load(imageUrl)
         .into(imageView);

【讨论】:

    【解决方案2】:

    您必须获取图片网址

    所以简单地使用 Glide

    将此行添加到您的应用级别 build.gradle

    dependencies {
      implementation 'com.github.bumptech.glide:glide:4.9.0'
      annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    }
    

    然后使用类似的东西

    
    // String imgUrl = ImageURL;
    
    String imgUrl = sharedaPrefManager.getInstance(this).getImgae();
    
    
    
    Glide.with(this).load(imgUrl).into(imageView);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-18
      • 2015-10-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多