java - The difference between implementation of back and cancelbutton? -


i m newbie trying learn java/android-programming.

i m doing app android in eclipse , created buttons. have , cancel button.

example:

i have edittext there can write in name. if write yourname , press backbutton, u go previous activity, if go same activity, still see name wrote in edittext.

but if press cancelbutton, go previous activity, when come back, yourname empty. "kill" or "stop" activity.

this code use backbutton, use cancel button? thank you.

public void onclick(view v) {     switch(v.getid()){     case r.id.buttonback:         intent intent = new intent (allactivity.this, menuactivity.class);         startactivity(intent);         break; 

for cancel button can use below method, kill activity.

 finish() 

so in code this:

 public void onclick(view v) {      switch(v.getid()){      case r.id.cancel:          finish();          break; 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

How to merge four videos on one screen with ffmpeg -

c - getting error: cannot take the address of an rvalue of type 'int' -