Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:49:29+00:00 2026-06-12T23:49:29+00:00

Hello I have a listview in which I load my JSON text and a

  • 0

Hello I have a listview in which I load my JSON text and a thumbnail image.
I’ve used code from the tutorial from http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/ and converted this from xml to load json.

Parsing text and images work in my listview but now I’ve added a second activity, like a detail view, in which I also want to show the same image as the thumbnail.
I use the ImageLoader class from lazylist tutorial.

The problem is that i cannot load this image in my detail view.
Does someone has suggestions how i can make this work?

My code CustomizedListView:

    `package com.example.androidhive;

    import java.util.ArrayList;
    import java.util.HashMap;

    import org.json.JSONArray;
    import org.json.JSONException;
    import org.json.JSONObject;
    import org.w3c.dom.Document;

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import com.example.androidhive.JSONParser;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class CustomizedListView extends Activity {


    // url om request te maken
    private static String URL = "http://www.iappministrator.com/OBDE/webservice/android_deelnemers_items.php";



    // JSON Node namen
    static final String TAG_ITEMS = "items";
    static final String TAG_TITLE = "title";
    static final String TAG_MESSAGE = "message";
    static final String TAG_DATE = "date";
    static final String TAG_IMAGES = "images";

    // Nieuws JSONArray
    JSONArray newsArray = null;

    ListView list;
    LazyAdapter adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // Hashmap voor listView
        ArrayList<HashMap<String, String>> newsList = new ArrayList<HashMap<String, String>>();

        // Maak een JSON Parser instance
        JSONParser jParser = new JSONParser();

        // Pakt JSON string uit URL
        JSONObject json = jParser.getJSONFromUrl(URL);

        try{
            // Pakt de Array van Nieuwsartikelen
            newsArray = json.getJSONArray(TAG_ITEMS);

            // Loop door alle Nieuwsartikels
            for(int i=0; i < newsArray.length(); i++){
                JSONObject c = newsArray.getJSONObject(i);

                // Het plaatsen van elk json item in variabele
                String title = c.getString(TAG_TITLE);
                String message = c.getString(TAG_MESSAGE);
                String date = c.getString(TAG_DATE);
                String images = c.getString(TAG_IMAGES);

                // maak een nieuwe HashMap
                HashMap<String, String> map = new HashMap<String, String>();

                // voeg elk item child node in de Hashmap -> value
                map.put(TAG_TITLE, title);
                map.put(TAG_MESSAGE, message);
                map.put(TAG_DATE, date);
                map.put(TAG_IMAGES, images);


                // voeg de HashList toe aan ArrayList
                newsList.add(map);
            }
        } catch(JSONException e){
            e.printStackTrace();
        }


        list=(ListView)findViewById(R.id.list);

        adapter=new LazyAdapter(this, newsList, R.layout.list_row, 
                new String[]{TAG_TITLE, TAG_MESSAGE, TAG_DATE, TAG_IMAGES}, new int[] {
                R.id.title, R.id.artist, R.id.duration, R.id.list_image});        
        list.setAdapter(adapter);


        // Click event for single list row
        list.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {


                String title = ((TextView) view.findViewById(R.id.title)).getText().toString();
                String date = ((TextView) view.findViewById(R.id.duration)).getText().toString();
                String message = ((TextView) view.findViewById(R.id.artist)).getText().toString();
                //String images = ((TextView) view.findViewById(R.id.list_image)).getText().toString();
                //ImageView thumb_image = (ImageView) view.findViewById(R.id.thumbnail); // thumb image
                String images = ((ImageView)view.findViewById(R.id.list_image)).getImageMatrix().toString();
                //String images = ((ImageView)view.findViewById(R.id.list_image)).toString();
                //String images = ((ImageView)view.findViewById(R.id.list_image)).getContext().toString();

                // Start de nieuwe intent

                Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
                //Bitmap bitmap = (Bitmap) in.getParcelableExtra(TAG_IMAGES);

                in.putExtra(TAG_TITLE, title);
                in.putExtra(TAG_DATE, date);
                in.putExtra(TAG_MESSAGE, message);
                in.putExtra(TAG_IMAGES, images);
                startActivity(in);

            }
        });     
    }   
}`

The code of the secondActivity:

    package com.example.androidhive;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;

import com.nostra13.example.universalimageloader.ImageGridActivity.ImageAdapter;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

public class SingleMenuItemActivity  extends Activity {

    // JSON node keys
    private static final String TAG_TITLE = "title";
    private static final String TAG_MESSAGE = "message";
    private static final String TAG_DATE = "date";
    private static final String TAG_IMAGES = "images";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.single_list_item);


        // getting intent data
        Intent in = getIntent();

        // Get JSON values from previous intent
        String title = in.getStringExtra(TAG_TITLE);
        String date = in.getStringExtra(TAG_DATE);
        String message = in.getStringExtra(TAG_MESSAGE);
        String images = in.getStringExtra(TAG_IMAGES);
        //Bitmap bitmap = in.getParcelableExtra(TAG_IMAGES);
        //ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image);

        // Displaying all values on the screen
        TextView lblTitle = (TextView) findViewById(R.id.title_label);
        TextView lblDate = (TextView) findViewById(R.id.date_label);
        TextView lblMessage = (TextView) findViewById(R.id.message_label);
        ImageView lblImages = (ImageView) findViewById(R.id.images_label); 
        //TextView lblImages = (TextView) findViewbyId(R.id.images_label);

        // loader image
        //int loader = R.drawable.loader;
        System.out.println("Ja en nu werkt het niet meer");

        // image url
        //String image_url = "http://d24w6bsrhbeh9d.cloudfront.net/photo/5614379_460s.jpg";

       //ImageLoader imgLoader = new ImageLoader(getApplicationContext());
        //-imgLoader.DisplayImage(song.get(CustomizedListView.TAG_IMAGES), lblImages);
        System.out.println("Error? haha bam jammer dan:");
       //imgLoader.DisplayImage(images, lblImages);
        System.out.println("Plaatjes?:"+ images);

        lblTitle.setText(title);
        lblDate.setText(date);
        lblMessage.setText(message);
        //lblImages.setImageURI(Uri.parse(images));

        //ImageLoader imageLoader = new ImageLoader(getApplicationContext());
        //imageLoader.DisplayImage(images,lblImages);

        //lblImages.setImageResource(images);
        //imageLoader.displayImage(images);
        //lblImages.setImageBitmap(bitmap);
        //lblImages.setImageResource(R.drawable.bitmap);
        //lblImages.setImageResource(images);
        /*if (d instanceof BitmapDrawable) {
            Bitmap bm = ((BitmapDrawable)d).getBitmap();
            //Maybe more code here?
            lblImages.setImageBitmap(bm);
    }*/
        //lblImages.setImageResource(images);
        //lblImages.DisplayImage(images);
        //lblImages.DisplayImage(images);
    }
}

the lazyAdapter:

`package com.example.androidhive;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class LazyAdapter extends BaseAdapter {

    private Activity activity;
    private ArrayList<HashMap<String, String>> data;
    private static LayoutInflater inflater=null;
    public ImageLoader imageLoader; 

    public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d, int listRow, String[] strings, int[] is) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

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

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.list_row, null);

        TextView title = (TextView)vi.findViewById(R.id.title); // title
        TextView artist = (TextView)vi.findViewById(R.id.artist); // artist name
        TextView duration = (TextView)vi.findViewById(R.id.duration); // duration
        ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image

        HashMap<String, String> song = new HashMap<String, String>();
        song = data.get(position);

        // Setting all values in listview
        title.setText(song.get(CustomizedListView.TAG_TITLE));
        artist.setText(song.get(CustomizedListView.TAG_MESSAGE));
        duration.setText(song.get(CustomizedListView.TAG_DATE));
        imageLoader.DisplayImage(song.get(CustomizedListView.TAG_IMAGES), thumb_image);
        return vi;
    }
}`
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:49:31+00:00Added an answer on June 12, 2026 at 11:49 pm

    just add this in the customized listview

    TAG_ITEMS = "items";
    static final String TAG_TITLE = "title";
    static final String TAG_MESSAGE = "message";
    static final String TAG_DATE = "date";
    static final String TAG_IMAGES = "images";
    
    public void onItemClick(AdapterView<?> parent, View view,
                                int position, long id) {
                              HashMap<String, String> map = newsList.get(position);
    
                            Intent in = new Intent(SingleMenuItemActivity.this, org.scout.android.library.LibraryDetail.class);
                            in.putExtra(TAG_TITLE, map.get(TAG_TITLE));
                            in.putExtra(TAG_MESSAGE, map.get(TAG_MESSAGE));                         
                            in.putExtra(TAG_DATE, map.get(TAG_DATE));
                            in.putExtra(TAG_IMAGES, map.get(TAG_IMAGES));
    
                            startActivity(in);
    

    And in you single menu item class get the extra and display image like so:

    Intent in = getIntent();
    final String image_url = in.getStringExtra(TAG_IMAGES);
    
    
    ImageView imgv = (ImageView) findViewById(R.id.ID);
    ImageLoader imageLoader = new ImageLoader(getApplicationContext());
    imageLoader.DisplayImage(iamge_url, imgv);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have completed the Hello Views tutorial from android developers (http://developer.android.com/resources/tutorials/views/hello-listview.html) I understood the
Hello I have this code to show image from folder in php : $handle
I was following the ListView official tutorial - [url]http://developer.android.com/resources/tutorials/views/hello-listview.html[/url], because I get the entries
I have been playing with the list activity tutorial here: http://developer.android.com/resources/tutorials/views/hello-listview.html which tells you
I am follow google's listview tutorial (http://developer.android.com/resources/tutorials/views/hello-listview.html) and I'm trying to ad an adview
Hello I'm trying to load my listview with data from a database via a
hello I have my code that connects to my ftp server $conn_id = ftp_connect($ftp_server);
Hallo all, I have a ListView which contains a Button in each line. The
Hallo all, I have a ListView, which contains an EditText in each of it's
Hello i have some simplified code here showing the problem i have. Basically i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.