Created
April 6, 2017 11:36
-
-
Save Aldo-f/1c57ff525c0b05289b95140d713dbf8f to your computer and use it in GitHub Desktop.
Enter name to continue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* OnClickListener will store the name as entered in the EditText view, in a String, | |
* then it will send the string to the next Activity for further use. | |
* | |
* Player won't proceed without entering a name; | |
* */ | |
namesField.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
playerNames = namesField.getText().toString(); | |
if (playerNames.equals("")) { | |
Toast msg = Toast.makeText(getApplicationContext(), "Enter a name.", Toast.LENGTH_SHORT); | |
msg.show(); | |
} else if (!(playerNames.equals(""))) { | |
Intent proceedToMain = new Intent(getApplicationContext(), MainActivity.class); | |
proceedToMain.putExtra("playerNames", playerNames); | |
startActivity(proceedToMain); | |
finish(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment