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 7792997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:20:52+00:00 2026-06-01T22:20:52+00:00

I have two ListFragments (A and B, which are actually SherlockListFragments ) and when

  • 0

I have two ListFragments (A and B, which are actually SherlockListFragments) and when I put a breakpoint in the onCreateOptionsMenu in both fragments, Fragment A is hit 3 times and Fragment B is hit 2 times. In addition, I am animating one of the menu icon when an AsyncTask is running and if I select an item in Fragment A, onCreateOptionsMenu is called again and the icon double up:

enter image description here

I’m not sure why onCreateOptionsMenu is called again because I’m just calling a method in the “details” fragment:

@Override
public void onListItemClick(final ListView l, final View v, final int position, final long id)
{
    DetailsFragment fragment = (DetailsFragment)getFragmentManager().findFragmentById(R.id.fragmentDetails);

    if (fragment != null && fragment.isInLayout())
    {
        fragment.DisplayItems();
    } 
    else 
    {
        final Intent listing = new Intent(activity.getApplicationContext(), DetailsFragmentActivity.class);
        startActivity(listing);
    }
}

UPDATE:

I’m using this code to animate the menu item:

private MenuItem refreshItem;   

private void DoRefresh() 
{
    final LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final ImageView ivRefresh = (ImageView)inflater.inflate(R.layout.refresh_view, null);

    final Animation rotation = AnimationUtils.loadAnimation(activity, R.anim.refresh);
    ImageView ivRefresh.startAnimation(rotation);

    refreshItem.setActionView(ivRefresh);

    //AsyncTask is kicked off here
}

@Override
public boolean onOptionsItemSelected(final MenuItem item) 
{
    if (item.getItemId() == R.id.refresh) {
        refreshItem = item;
        this.DoRefresh();
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}
  • 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-06-01T22:20:54+00:00Added an answer on June 1, 2026 at 10:20 pm

    From the documentation:

    “After the system calls onCreateOptionsMenu(), it retains an instance of the Menu you populate and will not call onCreateOptionsMenu() again unless the menu is invalidated for some reason. However, you should use onCreateOptionsMenu() only to create the initial menu state and not to make changes during the activity lifecycle.”

    My guess is that the menu is being invalidated by something you are doing. What does fragment.displayItems() do?

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

Sidebar

Related Questions

I have an application which has two Tabs. Both of these are ListFragments. The
I have a fragment based layout with two ListFragments (A and B), both contained
I have a ViewPager (extends FragmentPagerAdapter ) which holds two Fragments . What I
I created an app in which there are two fragments and in both fragments
I have a MainActivity which contains a tab bar with two fragments: MainFragment and
I have create a sample Fragment application. I have two fragments like list fragment
I have two classes (MVC view model) which inherits from one abstract base class.
I have two update panels on a page. And I want to update both
I have two queries that find both the Zip codes, and the States for
Have two tables say ABC and XYZ and contain one column which data will

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.