Adapters generally all inherit from BaseAdapter so they'll have access to
the method (this is exactly the same as the Java side, for what it's worth).
I don't know what your code looks like, but my guess is that you're doing
something along the lines of:

    var view = FindViewById<ListView>(Resource.Id.List);
    view.Adapter = new ArrayAdapter(.....); // or some other kind of adapter
    view.Adapter.NotifyDataSetChanged();

The last line won't compile since the Adapter property on ListView is of
type IListAdapter (
http://docs.mono-android.net/index.aspx?link=P%3aAndroid.Widget.ListView.Adapter
).

You can either cast the adapter when you want to access those methods:

    ((ArrayAdapter)view.Adapter).NotifyDataSetChanged();

Or you can keep a reference to the object with its type when you create it
(this is the approach I'd prefer):

    var adapter = new ArrayAdapter(......);
    view.Adapter = adapter;
    adapter.NotifyDataSetChanged();

On Thu, Sep 1, 2011 at 7:54 AM, Tomasz Cielecki <tom...@ostebaronen.dk>wrote:

> So that means I have to cast the ListAdapter to BaseAdapter to invoke
> that method?
>
> On Thu, Sep 1, 2011 at 1:35 PM, Greg Shackles <gshack...@gmail.com> wrote:
> > That method is available as part of Mono for
> > Android:
> http://docs.mono-android.net/index.aspx?link=M%3aAndroid.Widget.BaseAdapter.NotifyDataSetChanged
> >
> > On Thu, Sep 1, 2011 at 6:48 AM, Tomasz Cielecki <tom...@ostebaronen.dk>
> > wrote:
> >>
> >> Hello there,
> >>
> >> I have a asynchronous method loading data in the background, when that
> >> is finished I want to update my ListView with the data this method has
> >> loaded into an ObservableCollection. It seems that normally when
> >> coding java you can invoke the method notifyDataSetChanged on the
> >> ListAdapter, but this method seems to be missing in MonoDroid.
> >>
> >> So my question is, how do I update my ListView with this new data?
> >>
> >> --
> >> Med Venlig Hilsen / With Best Regards
> >> Tomasz Cielecki
> >> http://ostebaronen.dk
> >> _______________________________________________
> >> Monodroid mailing list
> >> Monodroid@lists.ximian.com
> >>
> >> UNSUBSCRIBE INFORMATION:
> >> http://lists.ximian.com/mailman/listinfo/monodroid
> >
> >
> > _______________________________________________
> > Monodroid mailing list
> > Monodroid@lists.ximian.com
> >
> > UNSUBSCRIBE INFORMATION:
> > http://lists.ximian.com/mailman/listinfo/monodroid
> >
> >
>
>
>
> --
> Med Venlig Hilsen / With Best Regards
> Tomasz Cielecki
> http://ostebaronen.dk
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to