I have a ListView
Activity
that uses a AsyncTask
to load data from the database. This Activity has an options menu that checks to see if there are any data items in the Activities ListView in onPrepareOptionsMenu()
.
If there are items, I enable one of the options that is shown on the ActionBar
that allows the user to delete the items.
Now, when the Activity starts, the AsyncTask starts and as onPrepareOptionsMenu() is run through while the AsyncTask is still running, this menu item is never enabled, unless the device is flipped and the listview data gets passed in as an instance, bypassing the AsyncTask.
So, in the AsyncTask's onPostExecute()
, I call invalidateOptionsMenu()
but that does not seem to be the menu to refresh (I have debugging code in onCreateOptionsMenu()
and onPrepareOptionsMenu()
, and neither is fired). Any help appreciated.