android - use invalidateOptionsMenu inside BaseAdapter -
i've searched net answers wasn't able find solution need. question how recreate menu again update cart count icon inside base adapter. app i'm working right app count items user ordered, has item categories. when go activity displays categories, cart updates can't in item adapter. code simple.
this line @ end of ordering item.
setnotifcount(db.getcartcount());
and function.
private void setnotifcount(int count){ mnotifcount = count; invalidateoptionsmenu(); }
it shows invalidateoptionsmenu();
error because cannot resolve method. tried using activitycompat.invalidateoptionsmenu() throws npe.
you cant call invalidateoptionsmenu() there no such method in base adapter. can pass activity context base adapter , call below.
((youractivity)context).invalidateoptionsmenu();
also calling activitycompat.invalidateoptionsmenu() through npe calling invalidateoptionsmenu on class , not object.
Comments
Post a Comment