Android / Java - Overriding -


i have 2 classes "baseactivity" , "childactivity" i.e. childactivity inherts baseactivity. question: in following code snippet, whenever press left button - logs me "i child activity". need if want call super class functionality default.

public class baseactivity extends activity implements onclicklistener {      protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);     };      protected void configuretitlebar(string title) {         imagebutton imgleftbutton = ((imagebutton) findviewbyid(r.id.actionbarleftbutton));         imgleftbutton.setonclicklistener(baseactivity.this);     }     @override     public void onclick(view v) {         if(v.getid() == r.id.actionbarleftbutton){             printcustomlog("i base");         }     } } 

child activity:

public class childactivity extends baseactivity implements onclicklistener{     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_child);          configuretitlebar("mytitle");     }     @override     public void onclick(view v) {          if(v.getid() == r.id.actionbarleftbutton){             printcustomlog("i child activity");         }     } } 

if want super class functionality, can

a) not override onclick() method @ (but don't think that's want)
b) call super.onclick(v) onclick() in child class.

the code in childactivity be.

@override public void onclick(view v) {     // check condition if want handle in child class     if(condition){         printcustomlog("i child activity");     }     // else, default, call base class's onclick()     else{         super.onclick(v);     } } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -