简体   繁体   中英

What's the view I should use in Glide.with() function

I'm developing an app and I want to display ArrayList in GridView for that I use an adapter the object includes 3 Strings. number, hint, imageURL

I want to put each object in the GridView I successfully put the number and hint because it's just setText but with the ImageURL , I want to display Image in an ImageView but I can't figure out why my program doesn't work

I'm using Glide.with(context).load(roadSign.getImageURL()).into(SIGN_IMAGE_VIEW);

The function is in the Adapter class

I don't think the problem is in the function I think something is wrong with the Image so I'm adding everything related

https://www.codepile.net/pile/Qe1XpjG9

If you need any more information please comment below

As far as I know, Glide takes context in Glide.with() so try this:

Glide.with(context).load(roadSign.getImageURL()).into(SIGN_IMAGE_VIEW);
Glide.with(view).load(roadSign.getImageURL()).into(SIGN_IMAGE_VIEW); 

Try to do this and if the view doesn't work try to add convertview object....coz glide takes view object now

  @NonNull
  public static RequestManager with(@NonNull View view) {
    return getRetriever(view.getContext()).get(view);
  }

The problem was that the image URL was HTTP and not HTTPs because I use android 8 and apparently it's not acceptable

i dont know imageurl but as you answered it is the http permission problem. you should add the following for http request in

AndroidManifest.xml

<application
       android:usesCleartextTraffic="true"
           //....
           />

and always use the listener to find the exception error

  Glide.with(context)
 .load(roadSign.getImageURL())
  .listener(new RequestListener() {
   @Override
   boolean onLoadFailed(@Nullable GlideException e, Object model,    
     Log.e(TAG, "Load failed", e);
     return false; // Allow calling onLoadFailed on the Target.
   }

   @Override
   boolean onResourceReady(R resource, Object model, Target<R> target,
       DataSource dataSource, boolean isFirstResource) {
     // Log successes here or use DataSource to keep track of cache hits and misses.
     return false;
   }
})
.into(imageView);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM