[英]How to load a photo with Picasso
我正在實施一個應用程序,我正在嘗試使用 picasso 加載照片,但我沒有得到任何結果。 我怎樣才能弄清楚? 這是我所做的:
public class FullScreenPhoto extends AppCompatActivity {
ActivityFullScreenPhotoBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding=ActivityFullScreenPhotoBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
//Retrieving image path
Intent intent = getIntent();
String path =intent.getStringExtra("image_path");
//value of path=/storage/emulated/0/Android/data/com.ticanalyse.mheath.bf/files/Pictures/AH144644_7972289747179568715.jpg
if (Objects.equals(path, "no_image")) {
binding.imageContainer.setVisibility(View.GONE);
binding.textView.setVisibility(View.VISIBLE);
}else{
Log.d("path",path);
binding.imageContainer.setVisibility(View.VISIBLE);
Picasso.get()
.load(path)
.into(binding.imageContainer);
}
}
}
我不確定 picasso 是否顯示來自 filePath 的圖像。 但是滑行可以做到這一點。
使用glide with listener,你一定可以實現圖像
Glide
.with(context)
.load(path)
.listener(object : RequestListener<Drawable> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
//TODO handle error images while loading photo
return true
}
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
//TODO use "resource" as the photo for your ImageView
return true
}
})
.into(binding.imageContainer)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.