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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:47:02+00:00 2026-06-10T17:47:02+00:00

I am trying to understand the ListView concept and how it works and I’m

  • 0

I am trying to understand the ListView concept and how it works and I’m trying to create my own adapter which extends BaseAdapter. For ArrayAdapter for instance, there is the notifyDataSetChanged() method which should be called after you’ve updated the array list which holds all your data, in order to refresh the ListView.

But I am creating my own subclass of BaseAdapter. That method is not available to me, or is it? How do i implement this method? Basically, what does that method do exactly, maybe I’ll understand then.

In case of the ArrayAdapter i’m guessing it looks at what position the ListView is currently displaying and it checks if it’s the same one as in the ArrayList after it was updated? Or…

It says that the method:

Notifies the attached observers that the underlying data has been
changed and any View reflecting the data set should refresh itself.

But how exactly does it refresh itself?

Can someone explain please?

  • 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-10T17:47:03+00:00Added an answer on June 10, 2026 at 5:47 pm

    I’ve figured it out. I couldn’t understand how the hell the adapter started and how did it know where to get the data from. When i extended the BaseAdapter class, in the constructor of that class I initialized the list of items that I wanted to see in the ListView. But I couldn’t figure out how these values would be used and when.

    So here’s the thing !!! :

    In the BaseAdapter there are some methods that need to be overridden. Among these, there is getCount().

    When the ListView is created and whatnot, it calls getCount(). If this returns a value different than 0 (I returned the size of the ArrayList which I’ve previously initialized in the constructor), then it calls getView() enough times to fill the screen with items. For instance, I initialized the ArrayList with 20 items. Because only 8 items initially fit on the screen, getView() was called 8 times, each time asking for the position it required for me to return (more precisely it wanted to know how the row would look like in the list on that specific position, what data it needed to contain). If I scroll down the list, getView() gets called over and over again, ’til I hit the end of the list, in my case 20 items / rows.

    What notifyDataSetChanged() does is … when called, it looks at what items are displayed on the screen at the moment of its call (more precisely which row indexes ) and calls getView() with those positions.

    i.e. if you’re displaying the first 8 items in the list (so those are the ones visible on the screen) and you add another item between the 2nd and 3rd item in the list and you call notifyDataSetChanged() then getView() is called 8 times, with positions starting from 0 and ending with 7, and because in the getView() method you’re getting data from the ArrayList then it will automatically return the new item inserted in the list alongside 7 out of the previous 8 (7 and not 8 because the last item went one position down, so it is not visible anymore), and the ListView will redraw, or whatever, with these items.

    Also, important to specify is that if you’ve implemented getView() correctly, you’ll end up recycling the items (the objects) already displayed (instead of creating new ones). See this video at around 12:00 minutes to see the correct way to implement getView()

    I’ve figured all this out by placing calls to LogCat in every method and following what was going on.

    P.S. This example also helped me a lot to understand.

    UPDATE

    Nowadays ListViews are not really used anymore. Android came out with the RecyclerView which does the recycling of the views for you, but knowing the basics of a ListView helps with understanding the RecyclerView.

    Here’s a link for reference: https://developer.android.com/guide/topics/ui/layout/recyclerview

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

Sidebar

Related Questions

Trying to understand the math of this code snippet. A token is provided which
what's my problem? I'm trying to create a custom adapter in the dialogue. I
I'm trying understand how try ... catch construction works in T-SQL. So I've read
I am trying to search through listview in VB.net 2008. It works fine with
I am trying to create a ListView that will be populated with the entries
I am new to Android and am trying to understand the compound view concept
I'm trying to implement a ListView on my app, but i'm trying to understand
I'm trying to create a grouped ListView for a Windows 8 Metro style app.
I am trying to realize a Class Based ListView which displays a selection of
I am trying to understand on which stage android OS is rendering layouts, in

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.