1

I have an app which features a webview as it's primary component. I want to allow the users to highlight (select) text in the webview, but NOT SHOW any of the contextual options like copy and paste. In my emulator running android 2.3.x this isn't a problem, i can select text and nothing happens. On the nexus device I get the contextual action bar, with copy and select all options. I want to allow the user to select text, but i dont' want them to be able to copy the text. Ideally i would like to surpress the action bar entirely, but need to do this in away that compiles when the minsdk is set to api level 8.

aamiri
  • 2,420
  • 4
  • 38
  • 58

1 Answers1

0

A hack is to clear the clipboard when your textbox is long clicked:

OnLongClickListener mOnLongClickListener = new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            ClipboardManager clipboard = (ClipboardManager)
        getSystemService(Context.CLIPBOARD_SERVICE);
        clipboard.setText("");
            return false;
        }
    };

http://developer.android.com/reference/android/text/ClipboardManager.html

ACC
  • 2,488
  • 6
  • 35
  • 61
  • This did not work at all. First of all when you return true in the onLongClick method, you can't select text. When i switched it to return false, the text was selectable but the contextual action bar appeared on the nexux galaxy. My set up is a little different but should be equivalent. I have my activity implement onLongClickListener and have the onLongClick() activity defined as so. IF this is not equivalent please let me know. – aamiri May 08 '12 at 17:23
  • I assumed that it is ok to show the copy paste options. My bad, sorry about that. And you are right, it should return `false`. – ACC May 08 '12 at 17:26