Time for action - writing the ReviewActivity class

As already said, we will need to set up our tabbed-layout structure in our Java code. Fortunately, Android provides a very useful TabActivity class that does much of the heavy lifting for us, providing us with a ready-made TabHost object with which we can construct the Activity tab structure.

  1. Open the ReviewActivity.java file generated earlier in an editor or IDE.
  2. Instead of extending Activity, change the class to inherit TabActivity:
    public class ReviewActivity extends TabActivity
    
  3. In the onCreate method, remove the setContentView(R.layout.main) line (generated by the android create project utility) completely.
  4. Now start by fetching the TabHost object from your parent class:
    TabHost tabs = getTabHost(); ...

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.