Is possible to determine when text is selected and when is not?
I was googling and I find onSelectionChanged()
method or setOnLongClickListener()
for determining when user longClick
s the editText so when he made selection, but in both cases it can't help me with determining, when the user is not selecting any text (I could set button invisible)...
You can check editText.getSelectionStart() and editText.getSelectionEnd() and check if those values are:
So:
The
getSelectionStart()
method will return the start of the selection anchor/cursor or -1 if the user has not selected any text. You could try using this.You can use
That should do it.