代码之家  ›  专栏  ›  技术社区  ›  clustervely

使用glide库,在自定义弹出窗口中显示图像

  •  1
  • clustervely  · 技术社区  · 6 年前

    我正在使用 RecyclerView adapter . 这就像这个联系人列表。

    在里面 适配器 ,

    Popup popup = new Popup(mContext); 
    final ImageView popupImv =(ImageView) popup.findViewById(R.id.imageView_custom);
    
    Glide.with(mContext).load(photoUri)
      .signature(new StringSignature(Long.toString(System.currentTimeMillis())))         
      .bitmapTransform(new CropCircleTransformation(mContext))
      .into(popupImv);
    

    Java语言lang.IllegalArgumentException:必须在非空视图中传递

    我该怎么办?

    1 回复  |  直到 5 年前
        1
  •  1
  •   aldok    6 年前

    您收到的错误只是因为“popupImv”是一个空对象。因此,当您使用“Glide”时,您会收到此错误。

    我建议您使用AlertDialog而不是popup。类似这样:

    AlertDialog.Builder popupDialogBuilder = new AlertDialog.Builder(this);
    ImageView popupImv = new ImageView(this);
    Glide.with(mContext).load(photoUri)
                    .signature(new StringSignature(Long.toString(System.currentTimeMillis())))
                    .bitmapTransform(new CropCircleTransformation(mContext))
                    .into(popupImv);
    popupDialogBuilder.setView(popupImv);
    AlertDialog alertDialog = popupDialogBuilder.create();
    alertDialogBuilder.show();