Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


ahmet yuva
ahmet yuva
17,595 Points

I try to set image from json data but it does not appear on my listviewitem

this is my json

contacts: [
id: "c200",
name: "Ravi Tamada",
email: "ravi@gmail.com",
address: "xx-xx-xxxx,x - street, x - country",
gender: "male",
image: "http://www.madam.com.tr/wp-content/uploads/2014/06/Tango-Siempre-80x80.jpg",
phone: {
mobile: "+91 0000000000",
home: "00 000000",
office: "00 000000"

i pars this json and i set these name, email, address, gender items but i can not set image in layout.

and this is my view adapter

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

        if (convertView == null) {
            // brand new
            convertView = LayoutInflater.from(mContext).inflate(R.layout.film_list_item, null);
            holder = new ViewHolder();

            holder.nameLabel= (TextView) convertView.findViewById(R.id.nameLabel);
            holder.emailLabel= (TextView) convertView.findViewById(R.id.emailLabel);
            holder.genderLabel= (TextView) convertView.findViewById(R.id.genderLabel);
            holder.addressLabel= (TextView) convertView.findViewById(R.id.addressLabel);
            holder.imageId= (ImageView) convertView.findViewById(R.id.imageId);

        else {
            holder = (ViewHolder) convertView.getTag();

        Film day = mFilmler[position];

        byte[] decodedString = Base64.decode(String.valueOf(holder.imageId), Base64.URL_SAFE);
        Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);


        return convertView;

    private static class ViewHolder {
        TextView nameLabel; // public by default
        TextView emailLabel;
        TextView genderLabel;
        TextView addressLabel;
        ImageView imageId;
how i can set this image url as an image in my listview ?

2 Answers


I'm not certain about if this will work, but it appears you need to download the image to the device first before you can use it. There appears to be a similar question at stackoverflow.

Jon Kussmann
Jon Kussmann
Courses Plus Student 7,254 Points

The easiest way to do so is using a third party framework such as Picasso. There is a tutorial on how to use it in the Android series with the building the Self Destructing Message app.

The link to the library is: Picasso

Once you've added it to your dependencies, it's as simple as adding the line:

'''Picasso.with(context).load("yourImageUrl").into(imageView); '''