How to get selectCursor on one click in text mode

Is it possible to select the cursor in one click in text form. By default, we get the selection cursor on long press. The selected text should appear in the edittext below. I've tried using a spannable string, so the threaded string comes to the edittext, but I want the user to be able to change the selection using the select cursor.

enter image description here

+3


source to share


2 answers


android:textIsSelectable

works. So the problem is that when you set a flag editable to false the setKeyListener and the overwriteable flag are called.

To fix this, in the onCreate of my activity, you must add:



tesxtView.setKeyListener(null);
tesxtView.setFocusable(true);

      

+2


source


try this:



 yourTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
         ClipboardManager clipboard =
        (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
    clipboard.setText(yourTextView.getText());
        }
    });

      

+1


source







All Articles