java - Retrieving Url String From ArrayList -


i'm having problem retrieving url strings succesfully put arraylist. see debug screenshot:

as can see, before getting point use picasso load image url, i'm getting url strings. however, reason when run app, i'm getting .error() drawable. assume there no issues imageview, adapter call etc. since i'm getting error drawable. issue string urls. here code adapter. note don't have interaction adapter nor imageview inside activity, except setadapter method. also, have uses permission internet in manifest file.

edit

i tried putting hard-coded string url inside of .load() method, , worked. guess problem either url i'm trying put, or string url retrieve code. still not sure one...

math119adapter:

public class math119adapter extends baseadapter {      arraylist<url> data;     context context;      public math119adapter(context context) {         this.context = context;         data = new arraylist<>();         resources res = context.getresources();         string[] tempurls = res.getstringarray(r.array.urls);         (int = 0; i<tempurls.length; i++) {             url tempurl = new url(tempurls[i]);             data.add(tempurl);         }     }      @override     public int getcount() {         return data.size();     }      @override     public object getitem(int position) {         return data.get(position);     }      @override     public long getitemid(int position) {         return position;     }      @override     public view getview(int position, view convertview, viewgroup parent) {         viewholder holder;         view row = convertview;         if(row == null) {             layoutinflater inflater = (layoutinflater) context                     .getsystemservice(context.layout_inflater_service);             row = inflater.inflate(r.layout.list_item_math119, parent, false);             holder = new viewholder(row);             row.settag(holder);         } else {             holder = (viewholder) row.gettag();         }         url url = data.get(position);         picasso .with(context)                 .load(url.tostring())                 .error(r.drawable.moonlanding)                 .fit()                 .centercrop()                 .placeholder(r.drawable.placeholder)                 .into(holder.myimageview);         holder.myimageview.settag(url);          return row;     } }  class viewholder {     imageview myimageview;      viewholder(view v) {         myimageview = (imageview) v.findviewbyid(r.id.noteimageview);     } }  class url {     string url;     url(string url) {         this.url = url;     } } 

you're using own url class, but...it doesn't override tostring() method, default implementation object used, which:

the tostring method class object returns string consisting of name of class of object instance, at-sign character `@', , unsigned hexadecimal representation of hash code of object. in other words, method returns string equal value of:

getclass().getname() + '@' + integer.tohexstring(hashcode())

so instead of proper url, picasso receive like:

com.onurcevik.mathtest.math119adapter$url@bdde370 

which of course not correct url.

one solution override tostring() in url class, url variable holds...um, url, used, eg. :

@override public string tostring() {     return url; } 

you might read java.net.url class, available on android.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -