A (175)

(Tuis.) #1
CHAPTER 14: Android Content Providers: Providing Data to Applications 517

Creating the Activity: ContactGalaxy.java


Let’s create a new Java class from scratch in the HelloUniverse project:



  1. Right-click on the /src folder and select the New ➤ Class menu sequence to
    open the New Java Class dialog, which will allow you to access the Package
    Selection dialog and the Superclass Selection dialog shown in Figure 1 4- 2.


Figure 14-2. Use the New Java Class dialog to create a public ContactGalaxy.java activity subclass in Eclipse



  1. Click on the Browse button, next to Package, and select the absolute.
    beginners.hellouniverse option shown in the middle of Figure 14-2. Click
    the Browse button next to Superclass and select the Activity - android.app
    superclass shown on the right side of Figure 14-2 to configure your new Java
    class for use. Name the class ContactGalaxy.

  2. Once you click the Finish button, Eclipse will open up the empty
    ContactGalaxy.java class, shown in Figure 14-3. You can copy and paste
    the first four lines of Java from MainActivity.java and change your UI layout
    reference to the activity_contact file that you are about to create next, which
    for now will generate an error highlight.

Free download pdf