6.6. MainActivity Subclass of Activity

Class MainActivity (Fig. 6.5) is host for the Cannon Game app’s CannonGameFragment. In this app, we override only Activity method onCreate, which inflates the GUI.


 1   // MainActivity.java
 2   // MainActivity displays the CannonGameFragment
 3   package com.deitel.cannongame;
 4
 5   import android.app.Activity;
 6   import android.os.Bundle;
 7
 8   public class MainActivity extends Activity
 9   {
10      // called when the app first launches
11      @Override
12      public void onCreate(Bundle savedInstanceState)
13      {
14         super.onCreate(savedInstanceState); // call super's onCreate method
15         setContentView(R.layout.activity_main); // inflate the layout
16      }
17   } // end class MainActivity


Fig. 6.5 | MainActivity displays the CannonGameFragment.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset