Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old January 7th, 2012, 05:11 PM   #1 (permalink)
Junior Member
 
Join Date: May 2011
Posts: 43
 
Device(s):
Thanks: 3
Thanked 4 Times in 1 Post
Default HelloTabWidget Tutorial Problems

I've spent a while going through the posts on here, stack overflow and elsewhere about this, but can't seem to get the HelloTabWidget tutorial to work.

As below, it won't run, say it has errors [AlbumsActivity cannot be resolved into a type.] and suggests adding [import superiorxc.examples.AlbumsActivity.AlbumsActivity;] for each Albums, Songs and ArtistsActivity, but this causes a ForceClosure when it runs (ERROR: [01-07 18:15:03.230: E/AndroidRuntime(326): java.lang.RuntimeException: Unable to start activity ComponentInfo{superiorxc.examples.hellotabwidget/superiorxc.examples.hellotabwidget.HelloTabWidgetA ctivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {superiorxc.examples.hellotabwidget/superiorxc.examples.ArtistsActivity.ArtistsActivit y}; have you declared this activity in your AndroidManifest.xml?]).

Would appreciate any feedback:

HelloTabWidget.java

Code:
package superiorxc.examples.hellotabwidget;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class HelloTabWidgetActivity extends TabActivity {
    /** Called when the activity is first created. */
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, ArtistsActivity.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("artists").setIndicator("Artists",
                          res.getDrawable(R.drawable.ic_tab_artists))
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, AlbumsActivity.class);
        spec = tabHost.newTabSpec("albums").setIndicator("Albums",
                          res.getDrawable(R.drawable.ic_tab_albums))
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, SongsActivity.class);
        spec = tabHost.newTabSpec("songs").setIndicator("Songs",
                          res.getDrawable(R.drawable.ic_tab_songs))
                      .setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(2);
    }
}
AlbumsActivity.java (+ ArtistsACtivity, SongsACtivity)

Code:
package superiorxc.examples.AlbumsActivity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class AlbumsActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        TextView textview = new TextView(this);
        textview.setText("This is the Albums tab");
        setContentView(textview);
    }
}
HelloTabWidget Manifest:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="superiorxc.examples.hellotabwidget"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".HelloTabWidgetActivity" >
        <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>

aSystemOverloa is offline  
Reply With Quote
Sponsors
Old January 12th, 2012, 11:33 AM   #2 (permalink)
Junior Member
 
Join Date: May 2011
Posts: 43
 
Device(s):
Thanks: 3
Thanked 4 Times in 1 Post
Default

Anyone have any ideas?
aSystemOverloa is offline  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 12:06 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo