java - Android string comparison to EditText string value -


i know should easy don't know i'm doing wrong.

i want pseudocode:

if edittext == "ed" {show.message "hi"}  else {show.message "nope"} 

//--[boton sumar 2]--  public void onbt_sumar2click(view v) {      edittext e1 = (edittext)findviewbyid(r.id.et_1);     edittext e2 = (edittext)findviewbyid(r.id.et_2);     textview t1 = (textview)findviewbyid(r.id.tv_resultado);      if (e1.gettext().equals("ed")){         context context = getapplicationcontext();         charsequence text = ":v / hi :v /" ;         int duration = toast.length_long;         toast toast = toast.maketext(context, text, duration);         toast.show();      }      else {         context context = getapplicationcontext();         charsequence text = "nope";         int duration = toast.length_long;         toast toast = toast.maketext(context, text, duration);         toast.show();     } } 

you should converting value of e1 string use of comparison.

try:

if (e1.gettext().tostring().equals("ed")) { ...


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -