0

这是我的主要活动程序。当我运行此代码时,模拟器显示不幸的是应用程序有 stopprd。请为此发布解决方案。在此先感谢.....我收到了许多应用程序的错误。所以这个答案将帮助我克服所有剩余的问题............

    package com.example.tab;

import android.app.Activity;
import android.content.res.Resources;
import android.net.http.AndroidHttpClient;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends Activity {
    private TabSpec tspec;
    private TabHost tabHost;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.activity_main);
        tabHost=(TabHost)findViewById(R.id.my_tabhost);
        tabHost.setup();
        Resources res=getResources();
        tspec=tabHost.newTabSpec("Tab1");
        tspec.setContent(R.id.clock);
        tspec.setIndicator("Clock");
        tabHost.addTab(tspec);
        tspec=tabHost.newTabSpec("Tab2");
        tspec.setContent(R.id.calendar);
        tspec.setIndicator("Calendar");
        tabHost.addTab(tspec);
        tspec=tabHost.newTabSpec("Tab3");
        tspec.setContent(R.id.date);
        tspec.setIndicator("Date");
        tabHost.addTab(tspec);

      }

这是我的清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.tab"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="12"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.tab.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
4

0 回答 0