slidingmenu - Use a container for Android activities -
i want know if android back upwards possibility create container static components , include activities in it. have sliding menu onclicklistener events , don't want set these events each activity.
if understood correctly, have functionality mutual several activities, , don't want repeat same code in of them. instead, want in 1 place.
one way accomplish create superclass activity, place mutual code in activity, , extend other activities. example,
public class baseactivity extends activity implements onclicklistener { private button button; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); button = (button) findviewbyid(r.id.my_button); button.setonclicklistener(this); } ... @override public void onclick(view view) { int id = view.getid(); switch(id) { case r.id.my_button: // perform action break; } }
}
then extend as
public class activity1 extends baseactivity { /... } public class activity2 extends baseactivity { /... } public class activity3 extends baseactivity { /... }
android slidingmenu
No comments:
Post a Comment