O'Reilly logo

Android User Interface Development by Jason Morris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - developing the main user interface Java code

In order to put this example together entirely and have a working content-centric screen (although only in the example sense), we need some Java code. This code will handle populating the user interface layout with an Album object. For this next piece of code, you'll need images for the cover art and for the artist's logo.

  1. Open the ShopActivity Java source file in an editor or IDE.
  2. In the onCreate method, ensure that the main.xml layout resource is being set as the content view for the ShopActivity:
    setContentView(R.layout.main);
    
  3. Fetch the application resources and invoke a new setAlbum method with the contents of your favorite music album:
    Resources resources = getResources(); setAlbum(new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required