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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:27:01+00:00 2026-06-09T20:27:01+00:00

Problem Statement:- In my below code, I am getting list of User’s which I

  • 0

Problem Statement:-

In my below code, I am getting list of User's which I am showing currently on the google map which is working fine for me. And also I need to show them on the ListView which is not working correctly.

So currently I have list of two user's in the response. And if I try to print them in the for loop, I can see both of the user getting printed correctly. But when I try to add them in my ListView, I see only one user getting shown on the ListView twice? But I should be seeing both the user one after another on the ListView.

@Override
protected void onPostExecute(ArrayList<User> response) {

    for(User user : response){

        System.out.println("User:- " +user.getFirstName());

// Something wrong I am doing in below line
        adapter=new LazyAdapter(ThesisProjectAndroid.this, mStrings, user);

        if(user.getGender()==1) {
            Drawable marker=getResources().getDrawable(R.drawable.current_user);
            int markerWidth = marker.getIntrinsicWidth();
            int markerHeight = marker.getIntrinsicHeight();
            marker.setBounds(0, 0, markerHeight, markerWidth);


            myItemizedOverlay = new MyItemizedOverlay(marker);
            mapView.getOverlays().add(myItemizedOverlay);

            GeoPoint myPoint1 = new GeoPoint((int) (user.getLatitude()*1000000), (int) (user.getLongitude()*1000000));
            myItemizedOverlay.addItem(myPoint1, "myPoint1", "myPoint1");
        } else {

            Drawable marker1=getResources().getDrawable(android.R.drawable.star_big_on);
            int markerWidth1 = marker1.getIntrinsicWidth();
            int markerHeight1 = marker1.getIntrinsicHeight();
            marker1.setBounds(0, 0, markerHeight1, markerWidth1);


            myItemizedOverlay = new MyItemizedOverlay(marker1);
            mapView.getOverlays().add(myItemizedOverlay);

            GeoPoint myPoint2 = new GeoPoint((int) (user.getLatitude()*1000000), (int) (user.getLongitude()*1000000));
            myItemizedOverlay.addItem(myPoint2, "myPoint2", "myPoint2");
        }

    }
    listView.setAdapter(adapter);
}

And this is my LazyAdapter class.

public class LazyAdapter extends BaseAdapter {

    private Activity activity;
    private String[] data;
    private static LayoutInflater inflater=null;
    public ImageLoader imageLoader;
    private User userList;

    public LazyAdapter(Activity a, String[] d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

    public LazyAdapter(Activity b, String[] mStrings, User user) {
        activity = b;
        data=mStrings;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
        userList = user;
    }

    public int getCount() {
        return data.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 vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.item, null);

        TextView text=(TextView)vi.findViewById(R.id.text);
        TextView text1=(TextView)vi.findViewById(R.id.text1);
        ImageView image=(ImageView)vi.findViewById(R.id.image);
        text.setText("Name: " +userList.getFirstName()+" "+userList.getLastName());
        text1.setText("Gender: " +userList.getGender());
        imageLoader.DisplayImage(data[position], image);
        return vi;
    }
}

And this is the XML for showing user's list– I need to show User's Full Name on one TextView and Gender on second TextView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <ImageView
      android:id="@+id/image"
      android:layout_width="50dip"
      android:layout_height="50dip" android:src="@drawable/stub" android:scaleType="centerCrop"/>
  <TextView
      android:id="@+id/text"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1" android:layout_gravity="left|center_vertical" android:textSize="20dip" android:layout_marginLeft="10dip"/>
   <TextView
      android:id="@+id/text1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1" android:layout_gravity="left|center_vertical" android:textSize="20dip" android:layout_marginLeft="10dip"/>
</LinearLayout>

And this is what I am getting in my Emulator- One User showing twice in my listview why is it so? But it should be One user information at the top and second user information below that.

  • 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-09T20:27:02+00:00Added an answer on June 9, 2026 at 8:27 pm

    You need to provide the complete list of users to your adapter

    @Override
    protected void onPostExecute(ArrayList<User> response) {
    
        // add all users to the adapter
        adapter=new LazyAdapter(ThesisProjectAndroid.this, mStrings, response);
    
        for(User user : response){
    
            System.out.println("User:- " +user.getFirstName());
    
            // ---- here be ur other code ----
        }
        listView.setAdapter(adapter);
    }
    

    Your Adapter

    public class LazyAdapter extends BaseAdapter {
    
        private Activity activity;
        private String[] data;
        private static LayoutInflater inflater=null;
        public ImageLoader imageLoader;
        private List<User> userList;
    
        public LazyAdapter(Activity a, String[] d) {
            activity = a;
            data=d;
            inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            imageLoader=new ImageLoader(activity.getApplicationContext());
        }
    
        public LazyAdapter(Activity b, String[] mStrings, List<User> user) {
            activity = b;
            data=mStrings;
            inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            imageLoader=new ImageLoader(activity.getApplicationContext());
            userList = user;
        }
    
        // ---- here be ur other code ----
    
        public View getView(int position, View convertView, ViewGroup parent) {
            View vi=convertView;
            if(convertView==null)
                vi = inflater.inflate(R.layout.item, null);
    
            TextView text=(TextView)vi.findViewById(R.id.text);
            TextView text1=(TextView)vi.findViewById(R.id.text1);
            ImageView image=(ImageView)vi.findViewById(R.id.image);
            text.setText("Name: " +userList.get(position).getFirstName()+" "+userList.get(position).getLastName());
            text1.setText("Gender: " +userList.get(position).getGender());
            imageLoader.DisplayImage(data[position], image);
            return vi;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem statement: It is necessary for me to write a code, whether which before
I am currently working on a C# WPF project. I have a list which
I have a problem when trying to execute this update statement (below) using C#
I have a problem with the SQL statement detailed below. The query returns the
So far I've got scrolling list items on click using the code below: $('li#news-back').click(function(){
I have the below Problem Statement PS: Given a string str and a Non-Empty
Below is the Problem Statement: PS: Given a string and a non-empty substring sub,
This is my below code which is drawing a Circle within Circle and taking
In my Top Half of the Android Screen, I am showing Google Map and
On the below line in my code I am getting a 1004 run time

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.