Sunday, 15 July 2018

Devices with Android + MIUI and setCustomSelectionActionModeCallback

I'm trying to create custom selection menu but it does not work on a device with rom MIUI and Android 6. The result is common menu with "copy" and "select all" items. On other devices and simulators under clean Android it works just fine. The code

       textViewTop.setCustomSelectionActionModeCallback(new android.view.ActionMode.Callback() {
        @Override
        public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {

            Log.d(LOG_TAG, "onCreateActionMode");

            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            Log.d(LOG_TAG, "onPrepareActionMode");
            menu.clear();

            int quote_quick = R.drawable.ic_desktop_mac_black_24dp;
            int quote_add = R.drawable.ic_computer_black_24dp;
            int copy = R.drawable.ic_devices_other_black_24dp;

            menu.add(Menu.NONE, QUOTE_START, 3, "").setIcon(quote_quick).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.add(Menu.NONE, QUOTE_ADD, 2, "").setIcon(quote_add).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.add(Menu.NONE, CUSTOM_COPY, 1, "").setIcon(copy).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
            return false;
        }

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

        @Override
        public void onDestroyActionMode(ActionMode mode) {

        }
    });



from Devices with Android + MIUI and setCustomSelectionActionModeCallback

No comments:

Post a Comment