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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:39:41+00:00 2026-06-12T05:39:41+00:00

ListView s ask Adapter s for View s before they can be seen on

  • 0

ListViews ask Adapters for Views before they can be seen on screen. The default implementation of an Adapter actually inflates your views when the ListView asks for them.

When using an Object extends ArrayAdapter<MyObject>, we could actually store all the views in a HashMap<MyObject, SoftReference<View>> and override ArrayAdapter.getView so we can inflate our Views only once, but if the GarbageCollector passes and makes our Views null (or my SoftReferences are made null for any strange reason) we inflate them again.

@Override
public View getView(final int position, final View convertView,
        final ViewGroup parent)
{
    final MyObject mo = getItem(position);
    if (hashMap.get(mo) == null || hashMap.get(mo).get() == null)
    {
        final MyCustomView mcv = new MyCustomView(getContext());
        hashMap.put(mo, new SoftReference<MyObject>(mcv));
    } 
    return hashMap.get(mo).get();
}

I’ve tried it and it works fine and nice. Is this implementation disencouraged in any way?

  • 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-12T05:39:43+00:00Added an answer on June 12, 2026 at 5:39 am

    we could actually store all the views

    You should use ViewHolder pattern. It allows you not to create all the views, but only those you need to display on the screen at the moment.

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

Sidebar

Related Questions

ListView listView; Activity activity; public ArrayList<Tasks> tasks; View v; public TaskAdapter(Activity activity, ArrayList<Tasks> tasks)
My Listview is setup in the details view with the following column headers: Image
Having ListView but I can customizing it only by modifying layout.xml (it's our system
The ListView shows nothing when I want to set the adapter to display the
In my Android application, I have a simple list view with adapter. There's a
I just want ask for your comments/suggestions on how to create a customized listview
In ListView I can change the divider image using android:divider=image but I want to
My Listview control contains 4 columns and 30 rows. I can retrieve the row
Hi i would like to ask for assistance on how to populate my ListView
I have a listview that displays files from a directory. The user can drag

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.