将此方法添加到我的类时出现此错误:

  @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;
  }

以下是我如何声明该类:
public class MainActivity extends SherlockActivity implements ActionBar.OnNavigationListener

我在其他项目中也有这种方法,但我不明白这个错误。有人知道为什么这个错误会在这里发生吗?
谢谢!

最佳答案

SherlockActivity确实会将这些方法重写为final,以便框架能够处理自身。
若要解决此问题,请仅从菜单、菜单项等中删除导入。从com.sherlockbar导入,因为您正在重写正确的方法。

关于android - Android-错误:无法覆盖SherlockActivity中的 final方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17933199/

10-11 22:23
查看更多