【问题标题】:How to put static image until download image from url using picasso如何放置静态图像,直到使用毕加索从 url 下载图像
【发布时间】:2016-07-26 11:56:23
【问题描述】:

在我的应用程序中,我有带有 imageview 的 listview。我正在使用 picasso 从 URL 下载图像。它工作完美。但我的问题是,下载需要一些时间。所以,我想从可绘制文件夹中显示图像,直到图像下载。一旦下载完成,然后在 imageview 中设置 URL 图像如何使用 picasso 在 android 中执行。

请任何人指导我!

提前致谢!!

【问题讨论】:

    标签: java android android-imageview imagedownload


    【解决方案1】:

    毕加索有一个用于显示占位符图像的内置函数。像这样使用它:

    Picasso.with(context)
       .load(imageUrl)
       .placeholder(R.drawable.image_name);
    

    【讨论】:

      【解决方案2】:

      使用此代码:

      Picasso.with(context)
         .load(url)
         .placeholder(R.drawable.placeholder).into(imageView);
      
      
      
       In above code:
           url is the url of image that you want to load into imageview. 
           R.drawable.placeholder is the placeholder image that is placed in your project drawable folder.
           imageview is the object of imageview into which you want to load image.
      

      【讨论】:

        【解决方案3】:

        您只需将您的 imageView 的静态可绘制图像放在您的 xml 文件中,如下所示:

        android:background="@drawable/image"`

        它会帮助你。

        【讨论】:

          【解决方案4】:

          毕加索同时支持download and error placeholders 作为可选功能。

          Picasso.with(context)
          .load(url)
          .placeholder(R.drawable.user_placeholder)
          .error(R.drawable.user_placeholder_error)
          .into(imageView);
          

          在显示错误占位符之前,将重试请求 3 次。

          更多信息http://square.github.io/picasso/

          这可能会对你有所帮助。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2016-03-12
            • 1970-01-01
            • 2015-09-06
            • 2018-07-11
            • 2016-07-31
            • 1970-01-01
            相关资源
            最近更新 更多