android 如何加载毕加索的照片

j2qf4p5b  于 2023-01-19  发布在  Android
关注(0)|答案(1)|浏览(123)

我正在实现一个应用程序,我试图用毕加索加载照片,但我没有得到任何结果。我该如何解决呢?以下是我所做的:

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);
    
            }
        }
    }
ldioqlga

ldioqlga1#

我不确定picasso是否显示来自filePath的图像,但是glide可以做到。
与听众一起使用滑音,你一定能达到形象

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)

相关问题