This imports an package, which define the Activity class. You can find the source file in "your ADT directory Isdklsourceslandroid-22\android app package com. example. editgyeeting; import android app. Activity public class MainActivity extends Activity i @override protected void onCreate(Bundle savedInstanceState)t super onCreate (savedInstancestate) setContentView(R layout activity main);
16 This imports an package, which define the Activity class. You can find the source file in “your ADT directory” \sdk\sources\android-22\android\app
This defines a package, and include your MainActivity class in the package This imports an package, which define the activity class You can Can you roughly guess the directory of find the source file in "your ADT your MainActivity java file based on the directory'Isdklsourceslandroid package name? 22\android app package com. example. editgrgeting; import android app. Activity public class MainActivity extends Activity i @Override protected void onCreate( Bundle savedInstanceState)i super onCreate(savedInstanceState) setFontentView(R layout activity_main); Declare a class 17
17 This defines a package, and include your MainActivity class in the package. Can you roughly guess the directory of your MainActivity.java file based on the package name? This imports an package, which define the Activity class. You can find the source file in “your ADT directory” \sdk\sources\android- 22\android\app Declare a class
This defines a package, and include your MainActivity class in the package This imports an package, which define the activity class You can Can you roughly guess the directory of find the source file in "your ADT your MainActivity java file based on the directory'Isdklsourceslandroid package name? 22\android app package com. example. editgrgeting; import android app. Activity public class MainActivity extends Activity i @Override protected void onCreate( Bundle savedInstanceState)i super onCreate(savedtnstanceState) setfontentView(R layout activity_main); Declare Declare the a class inheritance 18
18 This defines a package, and include your MainActivity class in the package. Can you roughly guess the directory of your MainActivity.java file based on the package name? Declare a class Declare the inheritance This imports an package, which define the Activity class. You can find the source file in “your ADT directory” \sdk\sources\android- 22\android\app
This defines a package, and include your MainActivity class in the package This imports an package, which define the activity class You can Can you roughly guess the directory of find the source file in "your ADT your MainActivity java file based on the directory'Isdklsourceslandroid package name? 22\android app package com. example. editgrgeting; import android app. Activity public class MainActivity extends Activity i @Override protected void onCreate( Bundle savedInstanceState)i suber onCreate(savedinstancestate) setContentView(Rlayout. activitylmain) Declare Declare the Specify the a class inheritance superclass 19
19 This defines a package, and include your MainActivity class in the package. Can you roughly guess the directory of your MainActivity.java file based on the package name? Declare a class Declare the inheritance Specify the superclass This imports an package, which define the Activity class. You can find the source file in “your ADT directory” \sdk\sources\android- 22\android\app
ava use the @override annotation to indicate that the method is created by overriding When we use this annotation for a method, it tells compiler that we are trying to override a superclass method, and enable the compiler to double check it for us if the method is indeed defined in the superclass http://ww.journaldev.com/817/overriding-methods-in- java-always-use-override-annotation package com. example/editgreeting; import android. a Activity; public class MinActivity extends Activity oVerride protected void onCreate(Bundle savedInstancestate)[ superonCreate(spvedInstancestate); setContentView(R layout activity_main); You can consider the on create Adopt the activity_ main xml method to be the entry point which is as the layout called first by the system in an app http://developer.androidcom/referencelandroid/app/activity.html
20 Java use the @Override annotation to indicate that the method is created by overriding. When we use this annotation for a method, it tells compiler that we are trying to override a superclass method, and enable the compiler to double check it for us if the method is indeed defined in the superclass. You can consider the onCreate method to be the entry point which is called first by the system in an app. Adopt the activity_main.xml as the layout http://developer.android.com/reference/android/app/Activity.html http://www.journaldev.com/817/overriding-methods-injava-always-use-override-annotation