How to insert an image into Dialog using the Glide library?

I'm trying to load it like this, but it doesn't work.

button3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(SkullActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog); ImageView image = (ImageView) dialog.findViewById(R.id.imageView3); image.setImageResource(Glide.with(this).load(R.drawable.history_button).asBitmap().format(DecodeFormat.PREFER_ARGB_8888).into(image)); dialog.show(); } }); 

Error in Glide.with(this) cant resolve method.

  • What exactly does "fail"? what is the problem? - Vladyslav Matviienko
  • Are you sure that ImageView image = (ImageView) dialog.findViewById (R.id.imageView3); not working null? - Vitalii Obideiko
  • 3
    I actually already managed to find the source of the library, and determine what your problem is, and even know the solution. But I will write the answer as soon as you complete the question, as it should be - indicating at least a specific problem. Not just "not working." - Vladyslav Matviienko
  • And what is the type of the parameter that must be passed to this method? Are you sure that you pass that parameter? - Vladyslav Matviienko

1 answer 1

The problem is that you are calling Glide.with(this) instead of Context sending OnClickListener

  • Sorry, but I wanted the author to learn something himself ... And you tell him "on a platter" ... - Vladyslav Matviienko
  • Sorry, I already saw your comment. I think, your comment in any case was to the author - miha_dev
  • That is okay, just wanted, as in the proverb about "give a man a fish, and he will be full 1 day ..." - Vladyslav Matviienko