Unable to override target method from ActionBarActivity

Now I am moving from ActionBarSherlock to the ActionBarCompat library, which was introduced in Google IO 2013 (I do this, so I can use ActionBarDrawerToggle).

I have already sorted all the necessary dependencies (AppCompat, the latest support library ...), fixed all the imports, but now when I try to use ActionBarActivity onMenuItemSelected , I get an error message.

 @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { ... } 

Error:

Unable to override target method from ActionBarActivity

The original method from ActionBarActivity (inherited from FragmentActivity ) is final. When I used ABS, it worked, now I can not override the method.

(MenuItem has an android.view.MenuItem class, not a compatibility version ...)

Did I miss something?

+6
source share
1 answer

Instead of using onMenuItemSelected I used onOptionsItemSelected and the compiled code is fine.

Could it be that onMenuItemSelected appears in documents, but not in code?

+11
source

Source: https://habr.com/ru/post/953036/


All Articles