I had problems updating a ListView (LV) and everytime I try to delete an item it promps me with the following error: The content of the adapter has changed but ListView did not receive a notification
.
But I do call notify()
on the LV here is my code:
public void deleteNotif(Reminder reminder)
{
NotificationDBHelper db = new NotificationDBHelper(getBaseContext());
this.mNotificationsHours.remove(reminder); // here I remove the element from the db
db.delete(reminder); // here I remove the element from the list
synchronized (this.mNotificationListLV)
{
Log.d("sync called","hi stackoverflow");
this.mNotificationListLV.notify();
}
}
And when I don't use the synchronized()
it prompt the error: object not locked by thread before notify()
; so I don't know what to do.
I call deleteNotify(Reminder reminder)
from a OnClickEventListener()
from one of the items inside the LV:
public NotificationButton(Context context, AttributeSet attrs) {
super(context, attrs);
//getAttr(context, attrs);
this.mImg.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
NotificationConfig nc = NotificationConfig.getInstance();
nc.deleteNotif(mReminder);
}
});
super.setImg(R.drawable.ic_delete_forever_black_24dp,0xc40003);
}
Thanks.