1

I've got something like this in my MainActivity.java

m_dbmanager.addRow(
                "http://pl.wikipedia.org/wiki/1_stycznia",
                "1",
                "http://assets3.parliament.uk/iv/main-large//ImageVault/Images/id_7382/scope_0/ImageVaultHandler.aspx.jpg");

1st quote is link which i send to webview in another activity, 2nd quote("1") is name of the row, and the last 3rd quote is url to image i want to show in a row.

and here is my part of code responsible for interaction with images.

public View getView(int position, View convertView, ViewGroup parent) 
        {
                View v = convertView;
                if (v == null) 
                {
                    LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.row, null);
                }
                Order o = items.get(position);
                if (o != null) 
                {
                        TextView name = (TextView) v.findViewById(R.id.row_textView);
                        ImageView image_view = (ImageView) v.findViewById(R.id.row_imageView);


                       if (name != null) 
                       {
                            name.setText("Name: "+o.getOrderName());                            
                       }
                       if(image_view != null)
                       {

                            final String thumbail = o.getOrderImage(); //TODO, just trying
                            final String link = o.getOrderLink();

                            image_view.setOnClickListener(new View.OnClickListener()

                            {
                                public void onClick(View view)
                                {       
                                    Intent intent = new Intent(MainActivity.this, TemplateActivity.class);
                                    intent.putExtra("urlString", link);
                                    startActivity(intent);
                                }
                            });
                        }
                }
                return v;
        }
    }

Order class in case someone would like to see

Now - what do I do to show the image from URL specified in addRow on place of object 'row_imageView'?

Thank you in advance,

Alan Kałuża
  • 515
  • 5
  • 19

1 Answers1

1

You could use the Picasso library to load an image from an URL into an ImageView.

Download the jar and add it to the libs folder of your project. Then use the code below to load the image from the url or even any other resource into the ImageView:

Picasso.with(your_context).load(url_of_image).placeholder(R.drawable.icon)
       .noFade().into(your_imageView);
Floern
  • 33,559
  • 24
  • 104
  • 119
Dakshesh Khatri
  • 639
  • 7
  • 12
  • Hey, thanks for that - looks simplest from all links i got here. But do you maybe know why this http://i.imgur.com/bMxsvot.png happens? It suggests me to change type of 'row_imageView' to 'Target' – Alan Kałuża Sep 10 '14 at 13:04
  • 1
    load or not ?? i think you wrote other imageview.. use 'image_view' instead of 'row_imageView' . – Dakshesh Khatri Sep 10 '14 at 13:13
  • Oook that was stupid mistake, thank you Daxesh. It works! Well, halfly :). It shows only placeholder, not the thumbail i gave it in .load() on all rows. Do you have any idea how do I fix that? In case if you would have time and want to check - here is my whole MainActivity.java http://pastebin.com/xyKWX4TC Sorry for using you :P – Alan Kałuża Sep 10 '14 at 13:24
  • 1
    Picasso.with(getContext()).load(new File(o. getOrderImage()).placeholder(R.drawable.ic_launcher) .noFade().into(image_view); try it dude:) – Dakshesh Khatri Sep 10 '14 at 13:32
  • Weird, still shows only placeholder images and this started jumping out in LogCat when i scroll http://pastebin.com/3B7JdMSj – Alan Kałuża Sep 10 '14 at 13:50
  • possible to load image – Dakshesh Khatri Sep 10 '14 at 13:51