Tab Layout tutorial incomplete?
Asked Answered
G

3

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?

Gomuti answered 23/2, 2010 at 15:48 Comment(2)
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.Unrobe
look at logcat to see where the RunTimeException is throwedCarducci
D
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.

Disaster answered 20/12, 2010 at 17:30 Comment(1)
Thanks for the reference. Any tips on recognizing a manifest omission?Ilysa
G
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

Gomuti answered 24/2, 2010 at 15:48 Comment(0)
W
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>
Woolf answered 24/12, 2010 at 1:14 Comment(2)
Ah! I was missing the <intent-filter> tags! Thanks mateDelaminate
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!Merlynmermaid

© 2022 - 2024 — McMap. All rights reserved.