You're right.
Even better! :-)

If you back just a simple java.util.List, then the ArrayAdapter will
take care of most, if not all, of your requirements for a list-view.

On Oct 21, 11:58 pm, Miguel Paraz <[email protected]> wrote:
> Hi Marc and "Streets of Boston",
>
> Thanks for the tips!
>
> As it turns out, subclassing is not necessary.
>
> The ArrayAdapter also works with java.util.List. I only found out
> while reading the source code (from the AOSP tree) to see how I can
> make a fork of it.
>
> Then, insert(object, index) will insert into the backing list you
> used, as well as redraw the UI.
>
> On Oct 21, 10:52 pm, Marc Lester Tan <[email protected]> wrote:
>
>
>
> > Yeah, correct, just call notifydatasetchanged on "you mean custom and not
> > customer ;)" adapter, forgot that one.
>
> > On Wed, Oct 21, 2009 at 10:02 PM, Streets Of Boston <[email protected]
>
> > > wrote:
>
> > > No need to call 'invalidate()' on your list-view.
> > > Call 'notifyDatasetChanged()' on your customer adapter instead,
> > > whenever you add or delete elements in your ArrayList or change the
> > > contents of existing elements in your ArrayList.
>
> > > On Oct 21, 7:53 am, Marc Lester Tan <[email protected]> wrote:
> > > > Hi Migs,
>
> > > > You can try creating custom adapter (subclassing BaseAdapter) backed by
> > > an
> > > > ArrayList. So lets say a new data comes in, get the currently selected
> > > > index, push your new data to arraylist, call invalidate on your listview
> > > > then call setSelection(position) on listview.
>
> > > > hth,
> > > > Marc
>
> > > > On Wed, Oct 21, 2009 at 7:34 PM, Miguel Paraz <[email protected]> wrote:
>
> > > > > Hi,
> > > > > I'd like to build a ListView with streaming content. New items are
> > > > > added to the top and old ones are forgotten
>
> > > > > If I understand correctly, the ListView was not built for this, right?
> > > > > The ListAdapter was meant to provide a fixed set of data.
>
> > > > > I tried to setAdapter() when new data comes in, but this makes the
> > > > > ListView forget the current selection.
>
> > > > > Is it feasible to subclass or modify ListView behavior so that the
> > > > > selection stays  the same but gets pushed down?
>
> > > > > Thanks!- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to