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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:15:17+00:00 2026-05-25T01:15:17+00:00

I’m becoming quite desperate with this issue, and I’ve been trying all the ideas

  • 0

I’m becoming quite desperate with this issue, and I’ve been trying all the ideas you all have been posting in other threads.

The problem is that my program makes massive calls to getView() method, and I implemented the Holder paradigm, but it’s still horribly slow, maybe someone can enlighten me?

This is my Adapter class:

    import java.util.ArrayList;

import android.content.Context;
import android.location.Location;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

    public class IconListViewAdapterPharmacy extends ArrayAdapter<PharmacyListItem> 
    {

    private ArrayList<PharmacyListItem> items;
    private Context cont;
    private Location l;

    public IconListViewAdapterPharmacy(Context cont, int textViewResourceId, ArrayList<PharmacyListItem> items, Location l)
    {
        super(cont, textViewResourceId, items);
        this.cont = cont;
        this.items = items;
        this.l = l;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) 
    {
        View v = convertView;

        PharmacyListItem o = items.get(position);
        ViewHolder holder = new ViewHolder();

        if (v == null) 
        {
            LayoutInflater vi = (LayoutInflater)cont.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.icon_row_pharmacy, null);

            holder.tt = (TextView) v.findViewById(R.id.pharmacy_row_toptext);
            holder.address = (TextView) v.findViewById(R.id.pharmacy_row_address);
            holder.distance = (TextView) v.findViewById(R.id.pharmacy_row_distance);
            holder.telephone = (TextView) v.findViewById(R.id.pharmacy_row_telephone);

         // associate the holder with the view for later lookup
            v.setTag(holder);
        }    

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

        holder.tt.setText(o.getName());     

        String add = "" + o.getAddress();
        holder.address.setText("" + add.substring(0, add.lastIndexOf(",")));

        holder.telephone.setText("" + o.getTelephone());

        String distancia = "" + o.getDistance();

        if(l != null)
        holder.distance.setText("Distancia: " + distancia);

        return v;
    }

        static class ViewHolder 
        {
            TextView tt;
            TextView address;
            TextView distance;
            TextView telephone;
        }
    }

The class PharmacyListItem:

    import android.location.Location;

    public class PharmacyListItem 
    {    
private String name;
private double lat;
private double lng;
private String telephone;
private double distance;

public PharmacyListItem(Location l, String name, double lat, double lng , String telephone)
{
    this.name = name;
    this.lng = lng;
    this.lat = lat;
    this.telephone = telephone;

    Location l2 = new Location(l);

    l2.setLatitude(lat);
    l2.setLongitude(lng);

    distance = l.distanceTo(l2);
}

public String getName()
{
    return name;
}

public String getAddress()
{
    return GeoLocator.getAddress(lat, lng);
}

public String getTelephone()
{
    return telephone;
}


public String getDistance()
{
    return (""+distance).substring(0, (""+distance).indexOf(".")) + "m.";
}

public double getDist()
{
    return distance;
}

}

Any ideas will be much appreciated!

Thank you all!

EDIT I paste here my .xml file:

<?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="?android:attr/listPreferredItemHeight"
android:padding="6dip"
android:layout_marginRight="4dip"
android:background="@drawable/bg_detalle_1"> 


      <ImageView
        android:id="@+id/arrow2" 
        android:layout_width="wrap_content"
        android:layout_centerVertical="true"
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"   
        android:singleLine="true"
        android:ellipsize="marquee"
        android:layout_marginRight="4dip"/>

      <LinearLayout android:padding="10dip" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout3" android:orientation="vertical">
          <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:layout_width="match_parent">
              <TextView android:gravity="center" android:textColor="#525252" android:layout_height="fill_parent" android:singleLine="true" android:ellipsize="marquee" android:text="" android:textStyle="bold" android:id="@+id/pharmacy_row_toptext" android:layout_width="wrap_content" android:layout_marginRight="6dip"></TextView>
          </LinearLayout>
          <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout2" android:layout_width="match_parent">
                  <TextView android:layout_height="fill_parent" android:text="TextView" android:id="@+id/pharmacy_row_address" android:layout_width="wrap_content" android:layout_marginRight="6dip"></TextView>
          </LinearLayout>

          <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/linearLayout5">
              <TextView android:gravity="center" android:layout_height="fill_parent" android:text="TextView" android:singleLine="true" android:ellipsize="marquee" android:layout_width="wrap_content" android:id="@+id/pharmacy_row_telephone"></TextView>
          </LinearLayout>

          <LinearLayout android:layout_gravity="right" android:layout_height="wrap_content" android:id="@+id/linearLayout5" android:layout_width="match_parent">
              <TextView  android:layout_height="fill_parent" android:text="TextView" android:singleLine="true" android:ellipsize="marquee" android:layout_width="wrap_content" android:id="@+id/pharmacy_row_distance"></TextView>
          </LinearLayout>
      </LinearLayout>          

</LinearLayout>
  • 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-05-25T01:15:18+00:00Added an answer on May 25, 2026 at 1:15 am

    Instead Of this

    public IconListViewAdapterPharmacy(Context cont, int textViewResourceId, ArrayList<PharmacyListItem> items, Location l)
    {
        super(cont, textViewResourceId, items);
        this.cont = cont;
        this.items = items;
        this.l = l;
    }
    

    do this

    public IconListViewAdapterPharmacy(Context cont, int textViewResourceId, ArrayList<PharmacyListItem> items, Location l)
    {
        super(cont, textViewResourceId, items);
        this.l = l;
    }
    

    Then In getView access items using getItem(position) instead of items.get(position) and to get context call getContext().

    Dont know if that will improve the performance. But no harm in trying. Also this is the correct way.

    Edit:

    Can get the address and update the UI later like you do if you had a profile image to be downloaded and shown.

    String add = "" + o.getAddress();
    if (TextUtils.IsEmpty(add)) {
        // download the geolocation. pass the position to the downloader thread which will update the item at position with address, after fetching is complete.
        new GetAddressTask(position).execute(o);
    } 
    

    This will free the UI thread to concentrate on displaying listview.

    class GetAddressTask extends Asynctask<.......> {
         int mPosition = -1;
         public void GetAddressTask(int position) {
             mPosition = position;
         }
         String doInBackground(parameters) {
             return GeoLocation.getaddress(parameter[0]);
         }
    
         void onPostExecute(String result) { // this runs on UI thread.
            // use mPosition here.
            // update addapter item with this address thats in 'result' variable.
           // and call adapter.notifyDatasetInvalidated()
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have been unable to fix a problem with Java Unicode and encoding. The
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this

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.