我试图让tabview应用程序工作,它在eclipse模拟器中工作正常,但是当试图在设备中安装它创建的四个应用程序时,每个不同的活动都在选项卡应用程序中使用,任何人都曾遇到这种问题。android tabview应用程序错误
从一些主要活动代码:
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Reusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, ArtistActivity.class);
spec = tabHost.newTabSpec("main").setIndicator("Main", res.getDrawable(R.drawable.ic_tab_main)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, AlbumActivity.class);
spec = tabHost.newTabSpec("camera").setIndicator("Camera", res.getDrawable(R.drawable.ic_tab_camera)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, SongsActivity.class);
spec = tabHost.newTabSpec("livemap").setIndicator("Live Map", res.getDrawable(R.drawable.ic_tab_livemap)).setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
xml文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tablayout.testing"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
<activity android:name=".TabLayoutDemoActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".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>
<activity android:name=".cameraActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".mapActivity"
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>
看起来像示例:: http://developer.android.com/resources/tutorials/views/hello-tabwidget.html – Ajay 2012-02-13 09:45:03