Android : Android Tab Child Activity notifyDataSetChanged() is not working

on Thursday, July 31, 2014


Android Tab child activity notifyDataSetChanged() is not working.I am trying to delete an item from listview using contextmenu list onItemClick(). Item is deleted but the view not updated. Here is my code.



@Override
public boolean onContextItemSelected(MenuItem item) {

AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item
.getMenuInfo();
String number;

try {

if (item.getTitle() == "Delete") {

DataBaseHandler db = new DataBaseHandler(MyShoppingCart.this);

db.deleteContact(listItems.get(info.position).getOrderNow());
Toast.makeText(MyShoppingCart.this.getParent(),
"" + info.position, Toast.LENGTH_LONG).show();
listView.removeViewAt(info.position);
ListAdapter.listItems.remove(info.position);//Adapter list item delete

adapter.notifyDataSetChanged();



}

else {
return false;
}
return true;
} catch (Exception e) {
return true;
}
}

}

0 comments:

Post a Comment