8

I've been trying to implement the tab UI described in this tutorial: https://developer.android.com/resources/tutorials/views/hello-tabwidget.html

I follow all the steps described in the process but I keep getting a runtime exception which I believe has something to do with the fact that nowhere in the tutorial I added the extra activities (songs, artists and albums) related to the content of each tab into the android manifest file.

Am I correct? is this tutorial (like many others) faulty or incomplete?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Bilthon
  • 2,461
  • 8
  • 36
  • 44
  • Utilize the `Log` class and leave debug statements inside your code block(s) that you believe are causing the problem. Once you have done that, enable the `LogCat` perspective and while your code is running it will print out a stacktrace to the console hopefully showing you where the `Runtime` exception is coming from. Once you have that, we have a better clue how to help. – Anthony Forloney Feb 23 '10 at 15:50
  • 1
    look at logcat to see where the RunTimeException is throwed – tbruyelle Feb 23 '10 at 15:51

3 Answers3

15

Since they seem to update these tutorials occasionally, I wouldn't doubt they forgot to mention this part back when this question was asked. They appear to have added a mention to this requirement in the tutorial now (as of 12/20/2010) in step 2:

Duplicate this for each of the three activities, and add the corresponding tags to the Android Manifest file.

Unfortunately, since these are beginner tutorials, they should probably include what the XML tags should look like. Prior to this tutorial, they don't mention how to add activities to the manifest (though you add an activity at the end for hiding the title bar). The markup I used was identical to that on the other question mentioned in the OPs own answer:

<activity android:name=".ArtistsActivity"></activity>
<activity android:name=".AlbumsActivity"></activity>
<activity android:name=".SongsActivity"></activity>

There is a full reference on manifest activities on the Android developer site.

patridge
  • 26,385
  • 18
  • 89
  • 135
3

Well thanks for the advice, but I didn't really had to use LogCat. The tutorial is indeed faulty and incomplete, the corrections are very well explained in this related post.

Issues with Android TabHost Example

I'm just amazed by the amount of mistakes in these tutorials, and by the fact that nobody has fixed them yet.

Nelson

Community
  • 1
  • 1
Bilthon
  • 2,461
  • 8
  • 36
  • 44
2

I was having the same problem, even after making all the corrections said above and on the following post link

the problem was the AndroidManifest, the following manifest file worked for me.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tabview.android" android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".HelloTabWidget" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".AlbumsActivity" android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar">
    </activity>
    <activity android:name=".ArtistsActivity" android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar">
    </activity>
    <activity android:name=".SongsActivity" android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar">
    </activity>
</application>


</manifest>
Community
  • 1
  • 1
Richipal
  • 721
  • 1
  • 9
  • 11
  • Ah! I was missing the `` tags! Thanks mate – Darcy Jul 12 '11 at 00:14
  • Funny, I know how to do this but I saw this post so I thought I would have a look. You wouldn't want to be brand new at this and try to follow that so called "Hello" tutorial, I mean, Hello! There is all kinds of stuff missing! It's 11/13/2011 right now and has not been fixed! –  Nov 13 '11 at 08:28