Search code examples
androidsearchtextfindsearchview

How find text programmatically?


Is there any way to find the text programmatically? I would like put a extensive text in a TextView or other way, and then to search for specific words, as if you used Ctrl + F. I don't found information, I found SearchView but these search data only of a View, no? Thanks in advance.


Solution

  • You can use the method .contains provided by the String class that "Returns true if and only if this string contains the specified sequence of char values" (Oracle Docs) within your algorithm for searching for text then based on what that method returns execute certain code to do what you want if the CharSequence exists or not.

    String Class (Oracle)