Android: Control input in EditText -
i want control input in edittext. if null show text message "null" , if not null show "not null". used code below not work me.
edittext edittext = (edittext) findviewbyid(r.id.edittext1); string aa=edittext.tostring(); if("".equalsignorecase(aa)==false) toast.maketext(getapplicationcontext(), "champs non vide", toast.length_long).show(); else toast.maketext(getapplicationcontext(), "champs vide", toast.length_long).show();
also used nothing.
edittext edittext = (edittext) findviewbyid(r.id.edittext1); string aa=edittext.tostring(); if(aa!=null) toast.maketext(getapplicationcontext(), "champs non vide", toast.length_long).show(); else toast.maketext(getapplicationcontext(), "champs vide", toast.length_long).show();
how can ? in advance help.
to check edittext
if empty or not can use :
edittext edittext = (edittext) findviewbyid(r.id.edittext1); if(edittext.gettext() != null && !textutils.isempty(edittext.gettext().tostring.trim()) { toast.maketext(youractivityname.this, "champs non vide", toast.length_long).show(); } else { toast.maketext(youractivityname.this, "champs vide", toast.length_long).show(); }
Comments
Post a Comment