0

I want to create an EditText with the following changes:

  1. Clicking on it will not show the keyboard
  2. After SINGLE, SHORT click it will get into selection mode (When I say selection mode I mean the mode where you can select a section of the text (with two pointers). You can get to this mode by long clicking on the text.)
  3. After text is selected the copy/paste/cut toolbar will not be shown

For the first, I guess I can create an OnTouchListener and return true immediately, but then it will block me from doing the second thing (which I have no idea how to do).

I looked for a command that gets the EditText into selection mode, but all I could find was a way to get the selected text from it...

Thanks!

EDIT: I successfully made 1 and 2, but the toolbar still shows (tried unregisterForContextMenu)

RE6
  • 2,684
  • 4
  • 31
  • 57

1 Answers1

0

you can use edittex.setCustomSelectionActionModeCallback

setCustomSelectionActionModeCallback(new Callback() {
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public void onDestroyActionMode(ActionMode mode) {                  
        }

        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

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

this will be block to open contextmenu for edittex

Adem
  • 9,402
  • 9
  • 43
  • 58
  • did you find any solution ? i too want the text to get selected on touch but no context menu to handle it – Dilroop Singh Dec 24 '15 at 21:15
  • getting no luck , tried above method but text is not getting selected. only one tracker appears for cursor shifter, require 2 but not context menu – Dilroop Singh Dec 24 '15 at 21:55