Wednesday, September 29, 2010

[android-developers] Re: Tab Layout not working

Thanks Mark.

I had looked at it, but can't quite make what' wrong:

It seems that the package name is prepended twice: com.exideas.mekb/
com.exideas.mekb.TabHolder

Other than that, TabHolder is included in the manifest:

<activity android:name="TabHolder"
android:theme="@android:style/Theme.NoTitleBar"
android:label="MessagEase Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Here's the barf part:

09-29 18:00:00.361: DEBUG/AndroidRuntime(1238): Shutting down VM
09-29 18:00:00.361: WARN/dalvikvm(1238): threadid=1: thread exiting
with uncaught exception (group=0x4001d800)
09-29 18:00:00.400: ERROR/AndroidRuntime(1238): FATAL EXCEPTION: main
09-29 18:00:00.400: ERROR/AndroidRuntime(1238):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.exideas.mekb/com.exideas.mekb.TabHolder}:
android.content.ActivityNotFoundException: Unable to find explicit
activity class {com.exideas.mekb/com.exideas.mekb.ArtistsActivity};
have you declared this activity in your AndroidManifest.xml?


Thank you.

On Sep 29, 6:05 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> Use adb logcat, DDMS, or the DDMS perspective in Eclipse to examine
> LogCat and look at the stack trace associated with your "barf".
>
>
>
> On Wed, Sep 29, 2010 at 8:39 PM, Saied <saie...@gmail.com> wrote:
> > Hi,
>
> > I am using the Tab Layout almost copied from the example provided. But
> > it's not working:
>
> > public class TabHolder extends TabActivity {
> >    /** Called when the activity is first created. */
> >    @Override
> >    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_info))
> >                      .setContent(intent);
>
> > // ok up to here
> >        tabHost.addTab(spec);    // barfs right here  **************
>
> >        // Do the same for the other tabs
> >        intent = new Intent().setClass(this,
> > MessagEaseSettings.class);
> >        spec = tabHost.newTabSpec("settings").setIndicator("Settings",
> >                          res.getDrawable(R.drawable.ic_tab_settings))
> >                      .setContent(intent);
> >        tabHost.addTab(spec);
>
> >        intent = new Intent().setClass(this, SongsActivity.class);
> >        spec = tabHost.newTabSpec("how").setIndicator("How",
> >                          res.getDrawable(R.drawable.ic_tab_how))
> >                      .setContent(intent);
> >        tabHost.addTab(spec);
>
> >        tabHost.setCurrentTab(2);
> >    }
>
> > }
>
> > seems that the problem happens when it adds the spec:
>
> >  tabHost.addTab(spec);
>
> > But there is not much to this:
>
> >  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_info))
> >                      .setContent(intent);
>
> > the activity (ArtistsActivity) exists and passes Eclipse's strict
> > checks.
>
> > the strings "artists" and "Artists" should not matter, and they are
> > taken from the exmple.
>
> > and the drawalbe.ic.tab.info does exist, exactly as the example
> > requires it:
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <selector xmlns:android="http://schemas.android.com/apk/res/android">
> >    <!-- When selected, use grey -->
> >    <item android:drawable="@drawable/tab_info_gray"
> >          android:state_selected="true" />
> >    <!-- When not selected, use white-->
> >    <item android:drawable="@drawable/tab_info_white" />
> > </selector>
>
> > Can anyone give me a hint as to where to look for? Any help is much
> > appreciated.
>
> > Best,
>
> > Saied
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android 2.2 Programming Books:http://commonsware.com/books

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment