java - Understanding android classes and methods -
can explain next code. understand classes , methods in java. not able understand in android.
public class mainactivity extends activity { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } }
i'll give +1 avoid question taken wrong one. it's valid one.
what don't understand it's design pattern android uses create if it's components. if have java background familiar instantianting object , changing properties like:
jframe f = new jframe() f.setsize(new dimension(50,50)); f.setvisible(true) // etc android's design pattern bit different. i'd phone call template/inheritance since of time you're going subclassing android components, but overriding it's default implementation this:
@override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } you're inheriting template (in case activity) , adding own logic within template.
to understand method does, need read documentation larn used for: http://developer.android.com/reference/android/app/activity.html
so, reply actual question, class activity, when instantiated, calls oncreate() method. in code you're overriding method does, , setting do:
java android
No comments:
Post a Comment