Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6983439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:25:08+00:00 2026-05-27T18:25:08+00:00

I have a ListView Activity that uses a AsyncTask to load data from the

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:25:09+00:00Added an answer on May 27, 2026 at 6:25 pm

    The issue was related to a bad global variable value. I was gatewaying the code inside the onPrepareOptionsMenu() method with a global boolean value that was never true, and had put the debugging statement INSIDE the boolean check… resulting in the debugging statement never running.

    After addressing that issue, everything is working as expected, code above is correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView in my activity that is populated from a database Cursor
I have an Activity that retrieves data from a web service. This data is
I have a ListView that uses Linkify to create a link to another activity
I have a main activity that takes elements from a database and displays them
I have a ListView that uses SimpleAdapter, each row has 2 TextViews, and I
I have a ListView activity that start a new intent. When Back pressed from
I have an Activity that uses a ListView to simply display a list of
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have a listview with a DataTemplate that has a ComboBox. I want the
I have an activity that extends ListView. I populate my list with the results

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.