3つのアクティビティでtabHostを作成したので、タブをクリックするとアクティビティが変更されます。インテントをタブで使用するとシャットダウン
これは最初のアクティビティのコードです:
public class estadisticas extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.estadisticas);
// TABS
Intent intent1 = new Intent(estadisticas.this, clasificacion.class);
Intent intent2 = new Intent(estadisticas.this, novedades.class);
Resources res = getResources();
TabHost tabHost = (TabHost) findViewById(R.id.mytabhost);
tabHost.setup();
//tab 1
TabSpec tab1 = tabHost.newTabSpec("estadisticas");
tab1.setIndicator(getString(R.string.statistics),res.getDrawable(R.drawable.estadisticastabs));
tab1.setContent(R.id.tab1);
tabHost.addTab(tab1);
//tab 2
TabSpec tab2 = tabHost.newTabSpec("clasificacion");
tab2.setIndicator(getString(R.string.scores),res.getDrawable(R.drawable.estadisticastabs));
tab2.setContent(intent1);
tabHost.addTab(tab2);
//tab 3
TabSpec tab3 = tabHost.newTabSpec("novedades");
tab3.setIndicator(getString(R.string.whatsnew),res.getDrawable(R.drawable.estadisticastabs));
tab3.setContent(intent2);
tabHost.addTab(tab3);
// END TABS
そして、私は両方(またはTAB2またはTAB3)をクリックしたときに、私はシャットダウンを取得します。
どこが間違っていますか?おかげさまで
TabHostのあなたの基本的な理解が正しくありません。 TabHostのすべてのタブ(tab1、tab2、tab3)はアクティビティestadisticasにあるため、クラッシュの原因となっているものがあります。あなたのLogcatを見せてください。 –
manifeastファイルにアクティビティを追加しましたか? –
はいマニフェストファイルで私の活動を得ました。 これは私LogCatある: 4月18日17:51:47.877:D/AndroidRuntime(3330):51:47.888:VM 04から18 17のシャットダウン/ dalvikvm(3330)W:= 3スレッドID:キャッチされない例外で終了スレッド(グループ= 0x4001b188) 4月18日17:51:47.888:Eは/ AndroidRuntime(3330):キャッチされないハンドラ:51:47.906:キャッチされない例外により 4月18日17に出るメインスレッドE/AndroidRuntime(3330):java.lang.IllegalStateException: 'public void setup(LocalActivityManager activityGroup)'を呼び出すことを忘れましたか? –