Reputation: 115
I have this code:
spinRoullete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (something) { check errors.}
if (something){something else}
If some errors exists stay there and show errors If errors doesn't exist go forward to next if .. And the errors
public void Errors () {
if (Rone.isChecked()) {
if (nr1.getText().length() == 0) {
nr1.setError("");
nr1.requestFocus();
} else {
nr1.setError(null);
}
} if (Rtwo.isChecked()) {
if (nr1.getText().length() == 0) {
nr1.setError("");
nr1.requestFocus();
} else {
nr1.setError(null);
}
if (nr2.getText().length() == 0) {
nr2.setError("");
nr2.requestFocus();
} else {
nr2.setError(null);
}
}
}
How can I make that? I'm new in this..
Upvotes: 0
Views: 74
Reputation: 1002
You can use return;
to exit the method anywhere, so if you make your method checkErrors() to return a boolean, you can do this:
spinRoullete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (something) {
if (check errors) {
return;
}
}
if (something) {
something else
}
}
});
Upvotes: 1