Home Ask Login Register

Developers Planet

Your answer is one click away!

Onur Çevik February 2016

Retrieving Url String From ArrayList

I'm having a problem with retrieving url strings that I succesfully put into my arraylist. See debug screenshot:

As you can see, before getting to the point where I use Picasso to load image from url, I'm successfully getting those url strings. However, for some reason when I run the app, all I'm getting is .error() drawable. I assume there are no issues with ImageView, Adapter call etc. since I'm successfully getting the error drawable. Issue is probably with those string urls. Here is the code for the Adapter. Note that I don't have any interaction with the adapter nor the imageview inside my activity, except for setAdapter method. Also, I have the uses permission for INTERNET in my manifest file.


I tried putting a hard-coded string url inside of the .load() method, and it worked. So I guess problem is either with the url I'm trying to put, or with my String url retrieve code. Still not sure which one...


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);
        for (int i = 0; i<tempUrls.length; i++) {
            Url tempUrl = new Url(tempUrls[i]);

    public int getCount() {
        return data.size();

    public Object getItem(int position) {
        return data.get(position);

    public long getItemId(int position) {
        return position;

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        View row = convertView;


Melquiades February 2016

You're using your own Url class, BUT...it doesn't override toString() method, so a default implementation from Object is used, which:

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

getClass().getName() + '@' + Integer.toHexString(hashCode())

so instead of your proper url, Picasso will receive something like:


which of course is not a correct url.

One solution would be to override toString() in your Url class, so that url variable which holds...um, url, is used, eg. :

public String toString() {
    return url;

You might also read about java.net.URL class, which is available on Android.

Post Status

Asked in February 2016
Viewed 3,923 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life