Search code examples
javaandroidarraylistandroid-edittextwords

How to check that whether words of arrayList are available in EditText in android


I have ArrayList of certain Words :

ArrayList<String> words = new ArrayList<String>();
words.add("this");
words.add("that");  

And i have EditText :

EditText name = (EditText) findViewById(userName);

Now I want to check that whether words of arrayList are available in name(EditText) :

Boolean WordsAvailable;
WordsAvailable = checkWords(name.getText().toString());

Now I want to make function to check whether words of arrayList are available or not in EditText as below:

public Boolean checkWords(String checkString)
{
    for(int i=0;i<words.size();i++)
    {
         // Here i want to check that whether words of arrayList are available in EditText
         If ( word is available )
        {
         return YES;
        }
    }
    return NO;
} 

How can i check this condition?


Solution

  • if(checkString.contains(words.get(i)))