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

  • SEARCH
  • Home
  • 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 8931595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:08:52+00:00 2026-06-15T09:08:52+00:00

I am trying to get image from URL then add it to a listview.

  • 0

I am trying to get image from URL then add it to a listview. I can successfully get the image, but I’m struggling with adding it to the listview.

I have tried this way:

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

    try {

        URL url = new URL("http://devcms.barcodo.com/Images/ProductImages/ThumbnailImages100/EG-BIRT-ST-JA_th.jpg");
        HttpGet httpRequest = null;
        httpRequest = new HttpGet(url.toURI());
        HttpClient httpclient = new DefaultHttpClient();
        HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
        HttpEntity entity = response.getEntity();
        BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
        InputStream input = b_entity.getContent();
        Bitmap bitmap = BitmapFactory.decodeStream(input); 

        HashMap<String, Object> docList = new HashMap<String, Object>();
        docList.put("IMAGE", bitmap);

        ArrayList<HashMap<String, Object>> al = new ArrayList<HashMap<String, Object>>();
        al.add(docList);

        simpleAdapter = new SimpleAdapter(this, al, R.layout.list_item,new String[] { "IMAGE" }, new int[] { R.id.image});
        lv.setAdapter(simpleAdapter);

Note: I am able to put it into an ImageView, but want to fetch into a listview.

  • 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-15T09:08:53+00:00Added an answer on June 15, 2026 at 9:08 am

    try the following:

             public class ImageURL extends ListActivity{
            @Override
         public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                    .permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        try {
    
            URL url = new URL(
                    "http://devcms.barcodo.com/Images/ProductImages/ThumbnailImages100/EG-BIRT-ST-JA_th.jpg");
            HttpGet httpRequest = null;
    
            httpRequest = new HttpGet(url.toURI());
    
            HttpClient httpclient = new DefaultHttpClient();
            HttpResponse response = (HttpResponse) httpclient
                    .execute(httpRequest);
    
            HttpEntity entity = response.getEntity();
            BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
            InputStream input = b_entity.getContent();
    
            bitmap = BitmapFactory.decodeStream(input);
    
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
    
        } catch (MalformedURLException e) {
            Log.e("log", "bad url");
        } catch (IOException e) {
            Log.e("log", "io error");
        }
        setListAdapter(new StudentListAdapter(this));
    }
    
    private class StudentListAdapter extends BaseAdapter {
        private Context mContext;
        private String[] mStudents = { "DurgaPrasad", "Raghu", "Vivek",
                "Satish", "Naga Jyothi", "Vardhika", "Nikhil" };
        private String[] mDetailsStudent = { "Details of DurgaPrasad",
                "Details of  Raghu This row is not created using java",
                "Details of Vivek", "Details of Satish",
                "Details of Naga Jyothi", "Details of Vardhika",
                "Details of Nikhil" };
    
        public StudentListAdapter(Context context) {
            mContext = context;
        }
    
        public int getCount() {
            return mStudents.length;
        }
    
        public Object getItem(int position) {
            return position;
        }
    
        public long getItemId(int position) {
            return position;
        }
    
        public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                System.out.println("111111111111 : " + position);
                LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
                /*
                 * if (position == 0) {
                 * System.out.println("111111111111 : "+position); v =
                 * vi.inflate(R.layout.studentdetailsrow, null);
                 * System.out.println("111111111111 : "+position); } else
                 */
                v = vi.inflate(R.layout.list_item, null);
            }
    
            ImageView iv = (ImageView) v.findViewById(R.id.icon);
            ImageView iv2 = (ImageView) v.findViewById(R.id.icon2);
            if (position == 0) {
                iv.setImageBitmap(bitmap);
                // iv2.setImageResource(R.drawable.icon);
            } else {
                iv.setImageBitmap(bitmap);
                // iv2.setImageResource(R.drawable.icon);
            }
    
            TextView tvname = (TextView) v.findViewById(R.id.stuname);
            TextView tvdetail = (TextView) v.findViewById(R.id.studetail);
            tvname.setText(mStudents[position]);
            tvdetail.setText(mDetailsStudent[position]);
            return v;
        }
    
        };
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get an image from URL and save it to the isolated
I am trying to get an image from URL in Android and set it
I'm trying to get an image off the internet from an URL in java.
Im trying to get an image from a wcf rest service like so: [ServiceContract]
I am trying to get an image from an HTTP server using Perl. I
Hi friends, I am trying to get the string data and image data from
I'm trying to get an image sitting at a URL that is protected by
So I've been trying to grab an image from an external URL, crop it
I'm trying to download an image from a url. The process I wrote works
OK, trying to get images from my SD card to show in an activity

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.