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 8311985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:00:16+00:00 2026-06-08T20:00:16+00:00

I have made a custom ArrayAdapter but it is not displaying the different images

  • 0

I have made a custom ArrayAdapter but it is not displaying the different images in each row of the list. It displays only the text but not the images from the server. Here is the code:
THE CUSTOM ADAPTER:

package com.findadoc;

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

public class doctorslistAdapter extends ArrayAdapter<Doctors> {
    Context context;
    int layoutResource;
    Doctors[]objects=null;
    public doctorslistAdapter(Context context, int resource, Doctors[] objects) {
        super(context, resource, objects);
        this.context=context;
        this.layoutResource=resource;
        this.objects=objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v=convertView;
        DoctorsHolder holder;
        if(v==null){
            LayoutInflater inflater=((Activity)context).getLayoutInflater();
            v=inflater.inflate(layoutResource, parent, false);
            holder=new DoctorsHolder();
            holder.doc_icon=(ImageView)v.findViewById(R.id.imageViewdocimg);
            holder.doc_name=(TextView)v.findViewById(R.id.textViewdocname);
            holder.specialization=(TextView)v.findViewById(R.id.textViewspecialization);
            v.setTag(holder);
        }
        else
        {
            holder=(DoctorsHolder)v.getTag();
        }
        Doctors doc=objects[position];
        holder.doc_icon.setImageBitmap(doc.bitmap);
        holder.doc_name.setText(doc.doc_name);
        holder.specialization.setText(doc.specialization);
        return v;
    }
    static class DoctorsHolder{
        ImageView doc_icon;
        TextView doc_name,specialization;
    }
}

THE DOCTORS CLASS:

package com.findadoc;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;

public class Doctors {
    public String doc_name,specialization;
    public Bitmap bitmap;
    public Doctors(String icon,String doc_name,String specialization){
        this.doc_name=doc_name;
        this.specialization=specialization;
        (new bitmapclass(icon)).execute();
    }
    class bitmapclass extends AsyncTask<Void, Void, Void>{
        public String icon_url;
        public Bitmap bm = null;
        public bitmapclass(String icon_url){
            this.icon_url=icon_url;
        }
        @Override
        protected Void doInBackground(Void... arg0) {
             try {
                    URL aURL = new URL("http://10.0.2.2/findadoc/images/"+this.icon_url);
                    URLConnection conn = aURL.openConnection();
                    conn.connect();
                    InputStream is = conn.getInputStream();
                    BufferedInputStream bis = new BufferedInputStream(is, conn.getContentLength());
                    bm = BitmapFactory.decodeStream(bis);
                    bis.close();
                    is.close();
               } catch (Exception e) {
                    e.printStackTrace();
               }
            return null;
        }
        @Override
        protected void onPostExecute(Void result) {
            Doctors.this.bitmap=bm;
            super.onPostExecute(result);
        }
    }
}

THE MAIN CLASS:

package com.findadoc;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

import com.findadoc.Doctors.bitmapclass;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ListView;

public class doctorsActivity extends Activity {
    ListView listviewdocs;
    ImageView imageview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.doctorsactivity);
        imageview=(ImageView)findViewById(R.id.imageViewtest);
        Doctors d=new Doctors("doc1.png", "", "");
        imageview.setImageBitmap(d.bitmap);
        listviewdocs=(ListView)findViewById(R.id.listViewDoctors);
        Doctors doctors_data[]=new Doctors[]{
                new Doctors("doc1.png", "Dr. Sammy Kulova","Gyaenacologist"),
                new Doctors("doc2.png","Dr.Joan Kulova","Paediatrician"),
                new Doctors("doc3.png","Dr. John Kulova","Pharmacist")
        };
        listviewdocs.setAdapter(new doctorslistAdapter(doctorsActivity.this, R.layout.doctors_list_item_row, doctors_data));
    }
}
  • 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-08T20:00:18+00:00Added an answer on June 8, 2026 at 8:00 pm

    Where is your XML file, you have to use an xml file in which you have to specify the contents of listview as ImageView and TextView. and that XML file goes to this line in getView() in adapter class

    (suppose it is list_row.xml)

    v=inflater.inflate(R.layout.list_row, parent, false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For MS CRM 2011 I have made custom workflow activity, but I'm not able
I am using JSF and have made a custom servlet for loading images dynamically.
I have images placed in following path res>drawable>Images>Currencies>[All images] I have made a custom
I have made custom .xml layout for ListView. Now it looks: But it isn't
I have made a custom list in which I am getting all the phone
I have made a custom ArrayAdapter for a ListView, in order to customize the
I have UIPageControl which I have made custom its dot color is not changing
I have made one custom user control (search text box), which basically consists of
i have made my custom keypad so i want to enter the text with
I have made a custom afterFind function in a model, but I just want

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.