문제

We have this default feature in android 3.0 that when we long press somewhere (say in a webview) action mode is started and as a result the action bar changes with many default features like copy, find etc.

Now what I want is that I want to start this action mode but not by long pressing on the web view. I want that when I load a webview I want this action mode automatically started without any long press. Is it possible ? Is there any method by which we can achieve this?

도움이 되었습니까?

해결책

In case you still need it or other people are looking for it

startActionMode(mContentSelectionActionModeCallback);

And as callback use:

    private ActionMode.Callback mContentSelectionActionModeCallback = 
       new ActionMode.Callback() {
    public boolean onCreateActionMode(ActionMode actionMode, Menu menu) 
    {
            //Here you can inflate a menu
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.name_menu, menu);

        return true;
    }

    public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
        return false;
    }

    public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) 
    {
        return false;
    }

    public void onDestroyActionMode(ActionMode actionMode) {
        awesomeAdapter.overviewFragment.stopEdit();
    }
};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top