java - Unable to solve conditional statement in the Android program -


i don't know problem in if statement. displays sorry in cat every time if put correct username , password. had remove whole program , start writing small demo code. please, check mistake there in if statement?

  @override     public void onclick(view v) {         switch (v.getid()){              case r.id.submitbutton:                 if (!(edtvusername.equals(" ") && (edtvpassword.equals(" ")))) {                    /* toast toast =  toast.maketext(loginactivity.this, "hi, forgot username/password", toast.length_short);                     toast.setgravity(gravity.center_horizontal | gravity.center_vertical,0,0 );                     toast.show();                     relativelayout.setbackgroundcolor(getresources().getcolor(r.color.red));*/                     log.i("tag","sorry");                  }                 else if(edtvusername.gettext().equals("aa") && edtvpassword.gettext().equals("aa")) {         /*                toast = toast.maketext(loginactivity.this, "successfully entered username/password", toast.length_short);                         toast.setgravity(gravity.center_horizontal | gravity.center_vertical,0,0 );                         toast.show();                         relativelayout.setbackgroundcolor(getresources().getcolor(r.color.green));*/                     log.i("tag","ok");                     }                 else{ log.i("tag","...................");}                 break;              case r.id.clearbutton:                 toast toast =  toast.maketext(loginactivity.this, "forgot username/password", toast.length_short);                 toast.setgravity(gravity.center_horizontal | gravity.center_vertical,0,0 );                 toast.show();                 relativelayout.setbackgroundcolor(getresources().getcolor(r.color.queenblue));         }       }      private void toastdef() {      } 

change this

if (!(edtvusername.equals(" ") && (edtvpassword.equals(" "))))  

to

 if (!(edtvusername.gettext().equals(" ") && (edtvpassword.gettext().equals(" "))))  

also in if condition true returned condition, false & false =false , !false gives true should use instead

 if(edtvusername.gettext().equals(" ") || edtvpassword.gettext().equals(" ")){   log.i("tag","sorry");  }      else{     ...     } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -