-1

Now i have a problem about highlight in EditText. - When i click the second time the highlight it will not work.

This my code

tv2.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    tv2.performLongClick();
                }
            });

I want to highlight every Onclick.

tv2.performLongClick(); enter image description here

pic2 highlight it not work enter image description here

Charuක
  • 12,953
  • 5
  • 50
  • 88

1 Answers1

2

If you want to highlight text inside editText Insted of tv2.performLongClick() you can simply use setSelectAllOnFocus(true)

Set the TextView so that when it takes focus, all the text is selected.

editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            editText.setSelectAllOnFocus(true);
            if (!hasFocus) {
             // noFocous
            }
        }
    });
Charuක
  • 12,953
  • 5
  • 50
  • 88