Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The method startSupportActionMode(ActionMode.Callback) is undefined for the type FragmentActivity?

I'm want to implement Action Mode Compact in Fragment Android. But I get error The method startSupportActionMode(ActionMode.Callback) is undefined for the type FragmentActivity in my code :

list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                    getActivity().startSupportActionMode(modeCallBack);

                    return true;
                }
        });

get error at getActivity().startSupportActionMode(modeCallBack);how to fix it ?

like image 271
Amay Diam Avatar asked Nov 30 '22 01:11

Amay Diam


1 Answers

From this ActionBarActivity startSupportActionMode (ActionMode.Callback callback) is method of ActionBarActivity which is used for ActionBar

if your Activity extend ActionBarActivity you can set like .

For ActionBarActivity

ActionBarActivity activity=(ActionBarActivity)getActiivty();
activity.startSupportActionMode(modeCallBack);

For Activity

getActivity().startActionMode(modeCallBack);
like image 118
kalyan pvs Avatar answered Dec 04 '22 13:12

kalyan pvs