Time for action - developing a simple memory game

Unlike almost all previous example, we'll generate the layout entirely in Java code in this game. The main reason for this is that the content is highly repetitive, each cell containing almost exactly the same widget. We use a TableLayout to create the grid, and display the "cards" in ImageButton widgets. To encapsulate the individual card behavior, we create a MemoryCard inner-class which holds a reference to the ImageButton it controls.

  1. Create a new Java class in the root package of your project, and name it TableLayoutActivity.
  2. Make the new class extend Activity:
    public class TableLayoutActivity extends Activity { Declare and array of all the icon resources to use as card images, there must be ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.