Coding

Tab Layout incomplete at google’s page [Android 2.0]

A lot of people have followed the tutorial in Google for making Tab’s layout in Android. I followed the guide but soon got into strange errors..

Bumping my head against the keyboard of reason that I did not find where the errors where, that was the cause of the application to crash each time.

For those that still have problems, here is some change of the code that must be made:

Step 2
When creating your activities in the manifest file (AndroidManifest.xml), it should looks like this afterwords:

[sourcecode language=”java”]
….






….
[/sourcecode]

Step 3

The text says that only create ic_tab_artist.xml file, but you will need to create the once for both songs and albums. Therefore create ic_tab_songs.xml and ic_tab_albums.xml and dublicate the data from ic_tab_artists.xml into both these new files.

Step 4

The third to last line under /res/layout/main has a typo, it should be a ; instead of an :
[sourcecode language=”java”]
….
android:padding=”5dp” />

….
[/sourcecode]

Step 6

There is an error when calling mTabHost, it should be tabHost.

Then on the last line there is a fault, when using getIntent().
Change this to:
[sourcecode language=”java”]
tabHost.setCurrentTabByTag(“albums”);
[/sourcecode]

Leave a Reply

Your email address will not be published. Required fields are marked *