I have a toast message that doesn't disappear after execution. Im guessing it has something to do with it being in the loop but I'm not sure. Can someone help me figure out what why the toast message doesn't disparate?
@Override
public void onClick(View v) {
int index = 0;
for(int i= 0; i<userArray.length; i++){
if(email.getText().toString().equals(userArray[i])){
index = i;
}
if(passArray[index].equals(password.getText().toString())){
Toast.makeText(getBaseContext(), "SUCCESS!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getBaseContext(), "INVALID LOGIN", Toast.LENGTH_SHORT).show();
}
}
Intent mainIntent = new Intent(LoginActivity.this, MainActivity.class);
startActivityForResult(mainIntent, 0);
}
}
Toast notifications are used to communicate low severity level information to users in an unobtrusive way. This notification will disappear after 8 seconds if not dismissed via the close button.
The toast can be dismissed automatically after a specific amount of time by passing the number of milliseconds to display it in the duration of the toast options. If a button with a role of "cancel" is added, then that button will dismiss the toast.
A toast message displays briefly, never receives focus, and disappears without user interaction. The default amount of time a toast message displays is 2 seconds, or if longDisplay is set to true, it displays for 3.5 seconds. The default length may vary depending on the version of the Android OS.
A Toast message can become stuck if you call it from a Service thread and that thread completes it's work before Toast is set to disappear. You are then stuck with the Toast message on the screen until you kill the app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With