I want from user to enter the amount of money and I want to reject the input if it contains any letters or symbols etc.In other words I want it to contain only numbers.One solution I ve come up with is the following.
final EditText numberField = (EditText) findViewById(R.id.Cost);
if(numberField != null) {
test = numberField.getText().toString();
}
if(test.isEmpty()) {
Toast.makeText(this, "Tutar alanını doldurunuz", Toast.LENGTH_SHORT).show();
}else if(test.contains("a")||test.contains("b")
} else {
cost = Integer.parseInt(test.trim());
}
I think this works but writing everything from test.contains("a") to test.contains("z") and the symbols is too long and makes the code look really bad. How can I accomplish my goal?