2016-10-07 62 views
-2

我是新来的picasso.using它我想动态获取图像,并能够更新图像,每当一些新的链接已更新。目前我只能为单个图像执行此操作。我使用的代码是:毕加索:在Android平台上动态添加多个图像。

picasso.with(this).load(url).into(image1) 

其中url是映像的url,image1是imageview。我想要反复地将5幅图像分成5幅不同的图像。我怎样才能做到这一点 ? 我也想删除缓存的毕加索图像,以便我可以用更新的图像进行更新。任何帮助,将不胜感激。

回答

0

在XML只需添加仅此,

<ViewFlipper 
android:id="@+id/flipper" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"> 
</ViewFlipper> 

比方说你的URL图像阵列这样。

String ImgAry[] = {"url1","url2","url3","url4","url5"} 

在你的onCreate()在你的活动文件

private void setImageInFlipr(String imgUrl) { 

    ImageView image = new ImageView(getApplicationContext()); 
    picasso.with(this).load(imgUrl).into(image); 
    viewFlipper.addView(image); 
} 
+0

我如何删除缓存图像

viewFlipper = (ViewFlipper) findViewById(R.id.flipper); for(int i=0;i<ImgAry.length;i++) { // create dynamic image view and add them to ViewFlipper setImageInFlipr(ImgAry[i]); } 

方法?如果我想 ? @rjz Satvara – user6930989

+0

只是使用这条线没有缓存... picasso.with(this).load(imgUrl).memoryPolicy(MemoryPolicy.NO_CACHE).into(image); –

+0

我只是这样做,但它说我们不能重写图像视图中的现有图像! – user6930989