This isn't a solution for me, but thanks.

On Apr 7, 4:55 pm, Jerry Fan <jerryfan1...@gmail.com> wrote:
> I have a fix for this. Just set the visibility of ur ListView to Gone during
> update and back to visible after update. By doing so, u can avoid the
> inconsistency of ur adapter and listView item count.
>
> On Wed, Mar 31, 2010 at 4:35 PM, ionel <ionelt2...@gmail.com> wrote:
> > I am calling notifyDataSetChanged() in update method
>
> > On Mar 30, 11:36 pm, social hub <shubem...@gmail.com> wrote:
> > > prob u need to call notifyDataSetChanged if data is changed. See if that
> > > helps
>
> > > On Tue, Mar 30, 2010 at 3:15 PM, ionel <ionelt2...@gmail.com> wrote:
> > > > I've implemented a custom ListView and  Adapter, and sometimes I
> > > > receive IllegalStateException exception:” ERROR/AndroidRuntime(3575):
> > > > java.lang.IllegalStateException: The content of the adapter has
> > > > changed but ListView did not receive a notification. Make sure the
> > > > content of your adapter is not modified from a background thread, but
> > > > only from the UI thread.”
>
> > > > Here is some code example:
>
> > > > public interface BuddyChangeListener {
>
> > > >     void onChange(List<Buddy> buddys);
>
> > > > }
>
> > > > public class BuddyListView extends ListView implements
> > > > BuddyChangeListener
>
> > > >   public void onChange(List<Buddy> Buddy) {
> > > >     MyActivity.instance.handler.post(new Runnable() {
> > > >                 public void run() {
> > > >                     if (((BuddyAdapter) refreshListView.getAdapter()) !
> > > > = null) {
> > > >                         ((BuddyAdapter)
> > > > refreshListView.getAdapter()).update(Buddy);
> > > >                     }
> > > >                 }
> > > >             });
> > > > }
> > > > public class BuddyAdapter extends BaseAdapter {
>
> > > >     private List<Buddy>       buddyList;
>
> > > >     public BuddyAdapter (Context context, List<Buddy> buddyList) {
> > > >         this.buddyList= buddyList;
> > > >     }
>
> > > >     public void update(List<Buddy> buddyList) {
> > > >         this.buddyList= buddyList;
> > > >         this.notifyDataSetChanged();
> > > >     }
> > > > }
>
> > > > Every time when the content of the list need to be updated I run from
> > > > onChange method and I use a handler to change the adapter content,to
> > > > update the content from UI thread.
>
> > > > Can someone to tell me if I have made something wrong on update ?
>
> > > > Thanks.
>
> > > > --
> > > > 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<android-developers%2bunsubscr...@googlegroups.com>
> > <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > To unsubscribe from this group, send email to android-developers+
> > > > unsubscribegooglegroups.com or reply to this email with the words
> > "REMOVE
> > > > ME" as the subject.
>
> > --
> > 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<android-developers%2bunsubscr...@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 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

Reply via email to