I’ve an application where the user keys in his friend’s information.My application have Spinner, 4 EditText and 3 Buttons(Save, Main Menu, View).
After the user click the Save button, if the user key in all required fields, it display Toast message “Your information is saved successfully! :D”, and if the user did not key in one or all required fields it display Toast message “Please key in all the required fields. :o”.
I’ve tried coding using if..else statement refering to my SMS application –
String contact_fname = sendTo.getSelectedItem().toString();
//String contact_fname = textName.getText().toString();
String message = messageTxt.getText().toString();
if (contact_fname.length() > 0 && message.length() > 0)
sendSMS(contact_fname, message);
else
Toast.makeText(getBaseContext(), "Please choose a sender's name and enter your message", Toast.LENGTH_SHORT).show();
I replaced them with Spinner, and the 4 EditText. I tried refering to these codes(SMS app) above, but it failed =(
I just need to display the toast message (which I’ve mentioned) after user press save Button
Anyone knows how to do this? I appreciate any help provided =)
Thanks!
Good thing is that you are using EditText. The reason it is good is that EditText comes with Form Validation. Not many use it though.
Example :
Hope this helps!