Everything is fine but I just want my app to check if the EditText is Empty or not, If it is empty then display a message and if not then it should proceed with the following code. Any help would be appreciated
public void guessNumber(View view) {
EditText guess = findViewById(R.id.guessText);
int guessnumber = Integer.parseInt(guess.getText().toString());
if(guessnumber>randomnumber) {
makeToast("Lower");
} else if(guessnumber<randomnumber) {
makeToast("Higher");
} else if(guessnumber==randomnumber) {
makeToast("You go me ! Try Again");
Random random = new Random();
randomnumber = random.nextInt(20)+1;
} else {
makeToast("Enter Something First");
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Random random = new Random();
randomnumber = random.nextInt(20)+1;
}
Use
TextUtils.isEmpty()
(See doc):