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

The Archive Base Latest Questions

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

I use a ListAdapter from this example: http://code.google.com/p/au-optimizing-layouts-201/source/browse/au_optimizinglayouts/src/com/example/android/training/optimizinglayouts/OptimizedListAdapter.java?r=4 The example is not very good,

  • 0

I use a ListAdapter from this example:

http://code.google.com/p/au-optimizing-layouts-201/source/browse/au_optimizinglayouts/src/com/example/android/training/optimizinglayouts/OptimizedListAdapter.java?r=4

The example is not very good, because elements in the list get drawn several times depending how fast I scroll. Thats because of the reuse of only one

private FakeImageLoader mFakeImageLoader;

If FakeImageLoader.java getImage() would load a real image.
What needs to be done to get this example running and stay performant?

public class OptimizedListAdapter extends BaseAdapter{

        ...
        private FakeImageLoader mFakeImageLoader;

public OptimizedListAdapter(Context cxt)
        {
                // Cache the LayoutInflate to avoid asking for a new one each time.
                mLayoutInflater = LayoutInflater.from(cxt);
                mFakeImageLoader = new FakeImageLoader(cxt);
                ...

 public View getView(final int position, View convertView, ViewGroup parent)
        {
        // A ViewHolder keeps references to children views to avoid unneccessary calls
        // to findViewById() on each row.
        ViewHolder holder;

                // When convertView is not null, we can reuse it directly, there is no need
        // to reinflate it. We only inflate a new View when the convertView supplied
        // by ListView is null.
                if(convertView==null)
                {
                        convertView = mLayoutInflater.inflate(R.layout.listitem, null);

                        // Creates a ViewHolder and store references to the two children views
            // we want to bind data to.
            holder = new ViewHolder();
            holder.icon = (ImageView) convertView.findViewById(R.id.listitem_image);
            holder.text = (TextView) convertView.findViewById(R.id.listitem_text);
            holder.timestamp = (TextView) convertView.findViewById(R.id.listitem_timestamp);
            convertView.setTag(holder);
                }else
                {
                        holder = (ViewHolder) convertView.getTag();
                }

                //holder.icon.setImageDrawable(drawable);
                holder.text.setText(new StringBuffer(ITEM_PRE_TEXT).append(position));
                holder.timestamp.setText(""+(System.currentTimeMillis()-START_TIMESTAMP));
        holder.position = position;

        //during a fast scroll this could start 100's of threads, need a thread pool processing them!
        //see previous ImageLoader.
                new AsyncTask<ViewHolder, Void, Bitmap>() {
                        private ViewHolder v;

                        @Override
                        protected Bitmap doInBackground(ViewHolder... params) {
                                v = params[0];
                                return mFakeImageLoader.getImage();
                        }

                        @Override
                        protected void onPostExecute(Bitmap result) {
                                super.onPostExecute(result);
                                if(v.position == position)
                                {
                                        v.icon.setImageBitmap(result);
                                }
                        }

                  }.execute(holder);
                  //holder.icon.setImageBitmap(mFakeImageLoader.getImage());

                return convertView;
        }

thanks Tata

  • 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-17T23:29:22+00:00Added an answer on June 17, 2026 at 11:29 pm

    I used this universal image loader library universal image loader library in one app to download images and it is more useful for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I an attempting to use a SQLiteFunction from my C# and ADO.NET code. Can
I use the most simpliest way in layout to define listview: <ListView xmlns:android=http://schemas.android.com/apk/res/android android:id=@android:id/list
I have modified this example from the SDK pages to grab all the Contact
I want to use custom List adapter in this example so that I can
use C#,want to upload excel file on google doc. bellow syntax use to upload
I have listview with some listadapter after click on item from list I'd like
How do I properly use ListAdapter.getView(int position, View convertView, ViewGroup parent) method? I'm having
I have a dialog in Android, as a layout I use this file: <?xml
I'm looking at the Notes app example from the Android SDK. What I want
everyone, i've a little problem how to use variable from another class file to

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.