5

I used SherlockActionBar in my application, but after I began to use appcompat. And get error

"The method startActionMode(ActionMode.Callback) in the type Activity is not applicable for the arguments (PageFragment.ActionModeCallback)"

in the raw

   mActionMode = getActivity().startActionMode(new ActionModeCallback());

Help me please, what I do incorrect?

nstCactus
  • 5,141
  • 2
  • 30
  • 41
user3176367
  • 135
  • 1
  • 3
  • 8
  • Thanks for posting the code. It's a bit long, though--can you please edit your question to include just the relevant parts? @Gopal asked for the imports section, so I imagine you need to include that, and perhaps the specific function which is raising the error. Only include the rest of the code if it's needed. – Wayne Conrad Jan 23 '14 at 11:09
  • 11
    mActionMode = ((ActionBarActivity) getActivity()).startSupportActionMode(new ActionModeCallback()); solution – user3176367 Jan 23 '14 at 11:12
  • @user3176367: you can post and accept your own answer.so that it can be helpful to others as well.people generally don't look at the comments. – Mehul Joisar Apr 03 '14 at 13:43

1 Answers1

17

Just to improve readability, according to user3176367, the solution was to cast the result of getActivity to ActionBarActivity.

Here is the working code:

((ActionBarActivity) getActivity()).startSupportActionMode(new ActionModeCallback()); 
nstCactus
  • 5,141
  • 2
  • 30
  • 41