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

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -