I am trying to create an app that checks the condition of a statement entered in an EditText field. At the moment, I have written if the word entered is 'next' which is not case sensitive to then proceed onto the next screen by pressing the 'Blogin' button.
My question is how do I write an 'if' statement so that if a phrase is entered into the EditText field and just any part of the phrase contains the word 'next' to then proceed to the next page by pressing the 'Blogin' button? For example if a phrase is entered as 'please go to the next page', the 'if' statement should recognise there is the word 'next' which shouldn't be case sensitive and hence allow you to proceed to the next page by pressing the 'Blogin' button.
Below is a snippet of part of the relevant code that needs to be changed:
public void onButtonClick(View v) {
if (v.getId() == R.id.Blogin) {
String str = a.getText().toString();
//Go to the next 'Display' window or activity if the person enters the correct username which is not case sensitive
if (str.equalsIgnoreCase("next")) {
Intent userintent = new Intent(MainActivity.this, Display.class);
startActivity(userintent);
} else {
Toast.makeText(getApplicationContext(), "Incorrect Information", Toast.LENGTH_SHORT).show();
}
}
}