I can underlined a word in edittext box using this method:
contentText.getEditableText().setSpan(new UnderlineSpan(), position, endLen, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
After i underlined the word, is there any methods that can let me know which word is underlined?This is because I need to know how many words and what is the word that had underlined. Thanks in advance for answering my question.
After i underlined the word, is there any methods that can let me know which word is underlined?
You already know what word is underlined. You just underlined it. Use position
and endLen
to retrieve the text that you underlined.
While you can call getSpans()
later on to retrieve the UnderlineSpan
, the UnderlineSpan
does not contain information about its position.