Search code examples
androidactionbarsherlock

Android - error: cannot override the final method in SherlockActivity


I am getting this error when adding this method to my class:

  @Override
  public boolean onCreateOptionsMenu(Menu menu) 
  {
      // Inflate your menu.     
      getSupportMenuInflater().inflate(R.menu.share_action_provider, menu);

      // Set file with share history to the provider and set the share intent.
      MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
      ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();        

      //actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
      // Note that you can set/change the intent any time,
      // say when the user has selected an image.
      actionProvider.setShareIntent(createShareIntent());

      return true;
  }   

Here is how I declare the class:

public class MainActivity extends SherlockActivity implements ActionBar.OnNavigationListener  

and I have this method in other projects and I dont' get that error. Would anyone know why this error started happening here?

Thanks!


Solution

  • SherlockActivity does override that methods as final so the framework can handle itself.

    To fix this, only delete the imports from Menu, MenuItems and etc.. and import from com.sherlockbar since you are overriding the correct method.