2016-07-26 83 views
0

在我的應用程序中,我有listview和imageview。我使用picasso從URL下載圖像。它的工作完美。但我的問題是,它需要一些時間來下載。所以,我想從可繪製文件夾中顯示圖像,直到圖像下載。一旦下載完成,然後在imageview中設置URL圖像如何在android中使用picasso。如何將靜態圖像,直到使用picasso從url下載圖像

請任何人指導我!

在此先感謝!

回答

4

畢加索具有內置的顯示佔位符圖像的功能。使用這樣的:

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

使用此代碼:

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. 
0

你只要把你靜態的繪製形象,爲您的ImageView在XML文件中,如:

的android:背景=「@ drawable/image「

它會幫助你。

0

畢加索支持download and error placeholders作爲可選功能。

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

的請求將被重試三次示出了錯誤的佔位符之前。

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

這可能幫助你。

相關問題