1

When user selects text in SearchView, the ActionMode will appear and show 2 tabs on the top, it seems ugly.

I tried some apps from Google like Gmail, inbox, Messenger, they disable the function, but how did they do? I tried to set the style, but failed.

Here is an example of Google IO 2014

enter image description here

GhostFlying
  • 809
  • 1
  • 7
  • 17

1 Answers1

2

You can try this:

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void disableActionMode(SearchView searchView) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ((EditText) searchView.findViewById(R.id.search_src_text)).setCustomSelectionActionModeCallback(new ActionMode.Callback() {
            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {

            }
        });
    }
}
Mattia Maestrini
  • 32,270
  • 15
  • 87
  • 94