0

I am using webview in one of my android projects(OS version 4.4+). Webview gives default functionality to select the text by "longpressing". But my project requirement is to select the text just by tapping on it and not by long pressing. I have tried methods mentioned in this link to achieve the functionality (Detect which word has been clicked on within a text). But it is not working for me. Can any one please guide how to achieve this task.

Community
  • 1
  • 1

1 Answers1

1

By this below method, you can select text by clicking on it after 1 second without needing to hold it:

webView.setOnTouchListener(new View.OnTouchListener() {
        Boolean tF;
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            tF = true;
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    tF = false;
            }
            return tF;
        }
});
M. Feyz
  • 359
  • 2
  • 9