Adding Items To Action Bar (using Actionbarsherlock)
I'm using ActionBarSherlock in my project and sometimes need to add one or more items inside the action bar. At this BaixadosFragment class (that extends SherlockFragment), I'm usi
Solution 1:
Your SherlockFragmentActivity also has an onCreateOptionsMenu()
and onPrepareOptionsMenu()
. You can inflate your menu options in the onCreateOptionsMenu()
by using getSupportMenuInflater()
. You would want to make a call to invalidateOptionsMenu()
in your SherlockFragmentActivity whenever you want the change to happen and add the menu options in onPrepareOptionsMenu()
. For more information look at the "Changing menu items at runtime" section of this link.
Solution 2:
If you are using a menu inside of a fragment, make sure you call setHasOptionsMenu(true);
in the fragments onCreate(Bundle savedInstance)
method
Post a Comment for "Adding Items To Action Bar (using Actionbarsherlock)"