I want to increase the duration of toast msg.I tried some code from some sites and also saw some yt videos but still the prob isn't solved.On clicking the button it displays the toast msg all at a time but i want it to display one by one on some time duration. Also I want to show toast msg that" all fields are compulsory" when even one or all edittexts are blank
public class NewUserActivity extends AppCompatActivity {
EditText name;
EditText email;
EditText phone;
EditText usname;
EditText passsword;
Button register;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_user_login);
name = (EditText) findViewById(R.id.name);
email = (EditText) findViewById(R.id.email);
phone = (EditText) findViewById(R.id.phone);
usname = (EditText) findViewById(R.id.usname);
passsword = (EditText) findViewById(R.id.passsword);
register= (Button) findViewById(R.id.register);
register.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String NAME = name.getText().toString().trim();
String EMAIL = email.getText().toString().trim();
String PHONENO =phone.getText().toString().trim();
String username = usname.getText().toString().trim();
String password = passsword.getText().toString().trim();
String emailPattern = "^[a-zA-Z0-9+_.-]{3,32}+@[a-zA-Z0-9.-]{2,32}+$";
String phonePattern = "(0/91)?[7-9][0-9]{9}";
// NAME VALIDATION
if(NAME.isEmpty()){
Toast.makeText(getApplicationContext(),"Plz Enter Name",Toast.LENGTH_SHORT).show();
}else if( !((NAME.length() > 3) && (NAME.length() < 15)) ){
Toast.makeText(getApplicationContext(),"Name > 3 and < 15",Toast.LENGTH_SHORT).show();
}else if(!NAME.matches("[a-zA-Z ]+")){
Toast.makeText(getApplicationContext(),"Only enter alphabets",Toast.LENGTH_SHORT).show();
}
//EMAIL VALIDATION
if(EMAIL.isEmpty()){
Toast.makeText(getApplicationContext(),"Plz Enter Email",Toast.LENGTH_SHORT).show();
}else if(!(EMAIL.matches(emailPattern))){
Toast.makeText(getApplicationContext(),"Invalid Email",Toast.LENGTH_SHORT).show();
}
//PHONE NUMBER VALIDATION
if(PHONENO.isEmpty()){
Toast.makeText(getApplicationContext(),"Plz Enter Phone no.",Toast.LENGTH_SHORT).show();
}else if(!(PHONENO.length()==10)){
Toast.makeText(getApplicationContext(),"Invalid Phone no.",Toast.LENGTH_SHORT).show();}
else if(!(PHONENO.matches(phonePattern))){
Toast.makeText(getApplicationContext(),"Invalid Phone Number",Toast.LENGTH_SHORT).show();
}
//USERNAME VALIDATION
if(username.isEmpty()){
Toast.makeText(getApplicationContext(),"Plz Enter Username",Toast.LENGTH_SHORT).show();
}else if(!((username.length() > 6) && (username.length() < 15))){
Toast.makeText(getApplicationContext(),"Username > 6 and < 15",Toast.LENGTH_SHORT).show();
}
//PASSWORD VALIDATION
if(password.isEmpty()){
Toast.makeText(getApplicationContext(),"Plz Enter Password",Toast.LENGTH_SHORT).show();
}else if(!((password.length() > 6) && (password.length() < 15))){
Toast.makeText(getApplicationContext(),"Password > 6 and < 15",Toast.LENGTH_SHORT).show();
}
}
});
}
}