tags:

views:

186

answers:

2

So I'm trying to build a tabs view for an Android app, and for some reason I get a force close every time I try to run it on the emulator. When I run the examples, everything shows fine, so I went as far as to just about copy most of the layout from the examples(a mix of Tabs2.java and Tabs3.java), but for some reason it still wont run, any ideas?

Here is my code(List1.class is a copy from the examples for testing purposes). It all compiles fine, just gets a force close the second it starts:

package com.jvavrik.gcm;



import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;

public class GCM extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final TabHost tabHost = getTabHost();

        tabHost.addTab(tabHost.newTabSpec("tab1")
                .setIndicator("g", getResources().getDrawable(R.drawable.star_big_on))
                .setContent(new Intent(this, List1.class)));

        tabHost.addTab(tabHost.newTabSpec("tab2")
                .setIndicator("C")
                .setContent(new Intent(this, List1.class))
                );
        tabHost.addTab(tabHost.newTabSpec("tab3")
                .setIndicator("S")
                .setContent(new Intent(this, List1.class))
                );

        tabHost.addTab(tabHost.newTabSpec("tab4")
                .setIndicator("A")
                .setContent(new Intent(this, List1.class))
                );

    }
}
+1  A: 

use "adb logcat" console cmd to catch exception message and stack trace from your emulator. it will show you what line of code causes an error

zed_0xff
perfect! I never used the adb before, that was stupid. It turns out I didn't update my manifest. In fact, I completely forgot about it. I dont know why I thought its auto-updated for all my classes and stuff.
James
A: 

Have you tried setting the current tab with setCurrentTab() or setCurrentTabByTag() after you have defined what each tab will be. I think at the moment android won't know which one to show first.

disretrospect
yeap, it still wouldnt work :'(
James