0

次のコードは例から取得しましたが、アプリは常にクラッシュします。

package com.example.tabview;

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

import android.view.Menu;


@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Resources ressources = getResources(); 
        TabHost tabHost = getTabHost(); 

        // Android tab
        Intent intentAndroid = new Intent().setClass(this, AndroidActivity.class);
        TabSpec tabSpecAndroid = tabHost
          .newTabSpec("Android")

          .setContent(intentAndroid);

        // Apple tab
        Intent intentApple = new Intent().setClass(this, AppleActivity.class);
        TabSpec tabSpecApple = tabHost
          .newTabSpec("Apple")

          .setContent(intentApple);

        // Windows tab
        Intent intentWindows = new Intent().setClass(this, WindowsActivity.class);
        TabSpec tabSpecWindows = tabHost
          .newTabSpec("Windows")

          .setContent(intentWindows);


        // add all tabs 
        tabHost.addTab(tabSpecAndroid);
        tabHost.addTab(tabSpecApple);
        tabHost.addTab(tabSpecWindows);

        //set Windows tab as default (zero based)
        tabHost.setCurrentTab(2);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

私はアンドロイドが初めてです。誰もこれについて私を助けることができます

ログキャット

07-01 14:48:25.127: E/AndroidRuntime(869): FATAL EXCEPTION: main
07-01 14:48:25.127: E/AndroidRuntime(869): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tabview/com.example.tabview.MainActivity}: java.lang.IllegalArgumentException: you must specify a way to create the tab indicator.
07-01 14:48:25.127: E/AndroidRuntime(869):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-01 14:48:25.127: E/AndroidRuntime(869):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-01 14:48:25.127: E/AndroidRuntime(869):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-01 14:48:25.127: E/AndroidRuntime(869):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-01 14:48:25.127: E/AndroidRuntime(869):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-01 14:48:25.127: E/AndroidRuntime(869):  at android.app.ActivityThread.main(ActivityThread.java:5041)
07-01 14:48:25.127: E/AndroidRuntime(869):  at java.lang.reflect.Method.invokeNative(Native Method)
07-01 14:48:25.127: E/AndroidRuntime(869):  at java.lang.reflect.Method.invoke(Method.java:511)
07-01 14:48:25.127: E/AndroidRuntime(869):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-01 14:48:25.127: E/AndroidRuntime(869):  at com.example.tabview.MainActivity.onCreate(MainActivity.java:46)
07-01 14:48:25.127: E/AndroidRuntime(869):  at android.app.Activity.performCreate(Activity.java:5104)
07-01 14:48:25.127: E/AndroidRuntime(869):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
4

1 に答える 1