Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

12. Slideshow App > 12.5. Building the App

12.5. Building the App

This app consists of classes SlideshowInfo (Fig. 12.14), Slideshow (a ListActivity subclass, Figs. 12.1512.24), SlideshowEditor (a ListActivity subclass, Figs. 12.2512.33) and SlideshowPlayer (Figs. 12.3512.39). This app’s main Activity, Slideshow, is created when you create the project, but you must change its superclass to ListActivity, then add the other classes to the project’s src/com.deitel.slideshow folder.


 1   // SlideshowInfo.java
 2   // Stores the data for a single slideshow.
 3   package com.deitel.slideshow;
 4
 5   import java.util.ArrayList;
 6   import java.util.List;
 7
 8   public class SlideshowInfo
 9   {
10      private String name; // name of this slideshow
11      private List<String> imageList; // this slideshow's images
12      private String musicPath; // location of music to play
13
14      // constructor
15      public SlideshowInfo(String slideshowName)
16      {
17         name = slideshowName; // set the slideshow name
18         imageList = new ArrayList<String>();
19         musicPath = null; // currently there is no music for the slideshow
20      } // end SlideshowInfo constructor
21
22      // return this slideshow's name
23      public String getName()
24      {
25         return name;
26      } // end method getName
27
28      // return List of Strings pointing to the slideshow's images
29      public List<String> getImageList()
30      {
31         return imageList;
32      } // end method getImageList
33
34      // add a new image path
35      public void addImage(String path)
36      {
37         imageList.add(path);
38      } // end method addImage
39
40      // return String at position index
41      public String getImageAt(int index)
42      {
43         if (index >= 0 && index < imageList.size())
44            return imageList.get(index);
45         else
46            return null;
47      } // end method getImageAt
48
49      // return this slideshow's music
50      public String getMusicPath()
51      {
52         return musicPath;
53      } // end method getMusicPath
54
55      // set this slideshow's music
56      public void setMusicPath(String path)
57      {
58         musicPath = path;
59      } // end method setMusicPath
60
61      // return number of images/videos in the slideshow
62      public int size()
63      {
64         return imageList.size();
65      } // end method size
66   } // end class SlideshowInfo


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint