Wednesday, June 23, 2010

[android-developers] Re: notifyDataSetChanged() not updating listview after orientation change

thisListView.setAdapter(r_adapter);
r_adapter.notifyDataSetChanged();

If you do 'setAdapter', calling notifyDataSetChanged() is not
necessary, if i'm not mistaken. But calling an extra
notifyDataSetChanged() should hurt.

Override the adapter's getItem and getCount methods and put a break-
point in these methods. See if these get hit and, if they do, see what
values they return.

On Jun 22, 11:55 pm, Bara <bara.kath...@gmail.com> wrote:
> Hmm... could it be my ArrayAdapter class causing the problem?
>
> This is how I call it:
>
> r_adapter = new ReminderAdapater(rData.getCurrentActivity(),
> remindersList, thisListView);
> thisListView.setAdapter(r_adapter);
> r_adapter.notifyDataSetChanged();
>
> And this is ReminderAdapater itself:
>
>     public class ReminderAdapater extends ArrayAdapter<Class_Reminder>
> {
>         ArrayList<Class_Reminder> items = new
> ArrayList<Class_Reminder>();
>         private ListView listView;
>
>         public ReminderAdapater(Activity activity, ArrayList<Class_Reminder>
> items, ListView listView) {
>             super(activity, 0, items);
>             this.listView = listView;
>             this.items = items;
>
>             Log.i("ReminderAdapater", "Constructor; Size: " + items.size());
>         }
>
>         @Override
>         public void add(Class_Reminder object)
>         {
>             Log.i("ReminderAdapater.add", "Item count = " + items.size());
>             super.add(object);
>         }
>
>         @Override
>         public View getView(int position, View convertView, ViewGroup parent)
> {
>             //... some view related stuff here, but it never actually gets to
> this point
>         }
>     }
>
> Do you guys see anything wrong with that?
>
> On Jun 22, 11:47 pm, Streets Of Boston <flyingdutc...@gmail.com>
> wrote:
>
>
>
> > The call to onRetainConfigurationChange and
> > getLastNonConfigurationInstance always works, if you have your
> > activity declared not to handle configuration changes by itself (which
> > it doesn't by default).
>
> > On Jun 22, 10:51 am, Gyan <gnanesh....@gmail.com> wrote:
>
> > > Classic problem!
>
> > > Use a static variable rather than onRetainConfigurationChange() lot of state
> > > data to be saved && doesn't work all the time!!
>
> > > Gyan- 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment