Android: Help with tabs view
Posted
by James
on Stack Overflow
See other posts from Stack Overflow
or by James
Published on 2010-06-03T01:55:25Z
Indexed on
2010/06/03
2:04 UTC
Read the original article
Hit count: 255
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))
);
}
}
© Stack Overflow or respective owner