The value returned by AdapterView.getCount is cached.

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/AdapterView.java#580

It's also updated after you've called notifyDataSetChanged:

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/AdapterView.java#794

The preceding call chain is:

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/BaseAdapter.java#45

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/database/DataSetObservable.java#30

I's also updated in a few other places (e.g. ListView.onMeasure), but the
right way to notify a list view about changed underlying data in an adapter
is notifyDataSetChanged.

-- K



2014-05-16 23:03 GMT+04:00 plnelson <pna...@gmail.com>:

>
>
> There's a lot of proprietary code in the adapter; I'll see if I can
> whittle it down to something simple but meanwhile I'd like to pursue the
> listview's strange getCount result.   Because that's a separate question
> from the getView()'s position value (maybe) I've started a separate thread
> focusing on that:
> https://groups.google.com/forum/#!topic/android-developers/Lx9_3H4RkhM
>
> This seems to have stumped them on Stack Overflow and I've never been able
> to get a clear description of where *exactly* the value in ListView's
> getCount() actually come from.
>
>
> On Friday, May 16, 2014 2:39:54 PM UTC-4, Streets Of Boston wrote:
>>
>> That is hard to figure out without you posting the code of your adapter
>> and how you create an instance of your adapter. It is probably a subtle
>> bug...
>>
>>>
>>>>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to