for reason, oncreateoptionsmenu
, onprepareoptionsmenu
run twice (checked log input on start of both methods). happens multiple fragments have, including basic (just inflating menu, nothing else).
this 1 of oncreateoptionsmenu
s has issue:
@override public void oncreateoptionsmenu(menu menu, menuinflater inflater) { inflater.inflate(r.menu.actionbuttons_add_removeall, menu); optionsmenu = menu; }
what cause these methods called multiple times (mostly twice)?
update
i found out being caused (in way) recyclerview
i'm using. views having issue use rv, view mentioned before didn't have issue, indeed doesn't. new info, part of rv possibly posing issue?
update2
i found out call .invalidateoptionsmenu()
in getitemcount()
method in adapter
. thought call onprepareoptionsmenu()
, reading docs, seems calls oncreateoptionsmenu()
. i'm getting oncreate..()
, onprepare..()
reversed here, gonna check out now.
update3
i have realized invalidate options menu in recyclerviewadapter
, in getitemcount()
method, runs when fragment first created.
@override public int getitemcount() { int tablesize = gettablesizemethod(); if (tablesize < 1) { if (!appmanagerfragment.hidedeleteallbutton) { appmanagerfragment.hidedeleteallbutton = true; ((activity) context).invalidateoptionsmenu(); return 0; } } else { if (!appmanagerfragment.hidedeleteallbutton) { appmanagerfragment.hidedeleteallbutton = false; ((activity) context).invalidateoptionsmenu(); return tablesize; } } }
this 1 own fault. invalidating options menu in getitemcount()
method of recyclerviewadapter
, runs when fragment initiated. can check out question code contains error. help/suggestions all.
Comments
Post a Comment