2011-04-29 47 views
0

我正在为TabActivity开发一个简单的示例...当我尝试运行时...它显示以下例外.... log cat view ....使用tabActivity运行应用程序时出错

04-29 16:13:04.870: ERROR/Zygote(33): setreuid() failed. errno: 2 
04-29 16:13:17.520: ERROR/Zygote(33): setreuid() failed. errno: 17 
04-29 16:13:20.940: ERROR/BatteryService(60): usbOnlinePath not found 
04-29 16:13:20.940: ERROR/BatteryService(60): batteryVoltagePath not found 
04-29 16:13:20.940: ERROR/BatteryService(60): batteryTemperaturePath not found 
04-29 16:13:20.980: ERROR/SurfaceFlinger(60): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake 
04-29 16:13:33.001: ERROR/EventHub(60): could not get driver version for /dev/input/mouse0, Not a typewriter 
04-29 16:13:33.001: ERROR/EventHub(60): could not get driver version for /dev/input/mice, Not a typewriter 
04-29 16:13:33.401: ERROR/System(60): Failure starting core service 
04-29 16:13:33.401: ERROR/System(60): java.lang.SecurityException 
04-29 16:13:33.401: ERROR/System(60):  at android.os.BinderProxy.transact(Native Method) 
04-29 16:13:33.401: ERROR/System(60):  at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146) 
04-29 16:13:33.401: ERROR/System(60):  at android.os.ServiceManager.addService(ServiceManager.java:72) 
04-29 16:13:33.401: ERROR/System(60):  at com.android.server.ServerThread.run(SystemServer.java:184) 
04-29 16:13:35.430: ERROR/SoundPool(60): error loading /system/media/audio/ui/Effect_Tick.ogg 
04-29 16:13:35.450: ERROR/SoundPool(60): error loading /system/media/audio/ui/KeypressStandard.ogg 
04-29 16:13:35.470: ERROR/SoundPool(60): error loading /system/media/audio/ui/KeypressSpacebar.ogg 
04-29 16:13:35.480: ERROR/SoundPool(60): error loading /system/media/audio/ui/KeypressDelete.ogg 
04-29 16:13:35.500: ERROR/SoundPool(60): error loading /system/media/audio/ui/KeypressReturn.ogg 
04-29 16:13:39.790: ERROR/ThrottleService(60): Could not open GPS configuration file /etc/gps.conf 
04-29 16:13:42.600: ERROR/logwrapper(153): executing /system/bin/tc failed: No such file or directory 
04-29 16:13:42.691: ERROR/logwrapper(154): executing /system/bin/tc failed: No such file or directory 
04-29 16:13:42.800: ERROR/logwrapper(155): executing /system/bin/tc failed: No such file or directory 
04-29 16:14:06.081: ERROR/HierarchicalStateMachine(60): TetherMaster - unhandledMessage: msg.what=3 
04-29 16:14:50.237: ERROR/AndroidRuntime(301): FATAL EXCEPTION: main 
04-29 16:14:50.237: ERROR/AndroidRuntime(301): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android/com.android.tab_sample}: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.os.Handler.dispatchMessage(Handler.java:99) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.os.Looper.loop(Looper.java:123) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.app.ActivityThread.main(ActivityThread.java:4627) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at java.lang.reflect.Method.invokeNative(Native Method) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at java.lang.reflect.Method.invoke(Method.java:521) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at dalvik.system.NativeStart.main(Native Method) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301): Caused by: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.app.TabActivity.onContentChanged(TabActivity.java:105) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.app.Activity.setContentView(Activity.java:1647) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at com.android.tab_sample.onCreate(tab_sample.java:14) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
04-29 16:14:50.237: ERROR/AndroidRuntime(301):  ... 11 more 
04-29 16:29:46.777: ERROR/AndroidRuntime(738): FATAL EXCEPTION: main 
04-29 16:29:46.777: ERROR/AndroidRuntime(738): **java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android/com.android.tab_sample}: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'** 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.os.Handler.dispatchMessage(Handler.java:99) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.os.Looper.loop(Looper.java:123) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.app.ActivityThread.main(ActivityThread.java:4627) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at java.lang.reflect.Method.invokeNative(Native Method) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at java.lang.reflect.Method.invoke(Method.java:521) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at dalvik.system.NativeStart.main(Native Method) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738): Caused by: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.app.TabActivity.onContentChanged(TabActivity.java:105) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.app.Activity.setContentView(Activity.java:1647) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at com.android.tab_sample.onCreate(tab_sample.java:14) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
04-29 16:29:46.777: ERROR/AndroidRuntime(738):  ... 11 more 

和我的代码是....

package com.android; 

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

public class tab_sample extends TabActivity { 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.tab_sample); 
     TabHost tab=(TabHost)findViewById(R.id.tabhost); 
     tab.setup(); 
     Resources res=getResources(); 
     //tab=getTabHost(); 
     Intent int1=new Intent(this,tab1.class); 
     Intent int2=new Intent(this,tab2.class); 
     tab.addTab(tab.newTabSpec("tab1").setIndicator("Songs",res.getDrawable(R.drawable.tab1)).setContent(int1)); 
     tab.addTab(tab.newTabSpec("tab2").setIndicator("Movie",res.getDrawable(R.drawable.tab2)).setContent(int2)); 
     //tab.addTab(tab.newTabSpec("tab3")) 
     tab.setCurrentTab(0); 
    } 

} 

请帮我解决这个问题....

回答

0

一些重要logcat的线路有:

16:29:46.777:错误/ AndroidRuntime(738):引起:java.lang.RuntimeException:您的内容必须具有一个TabHost,其id属性是'android.R.id.tabhost'04-29 16:29:46.777 :

它似乎无法找到你的ID,但这很奇怪,因为这应该会给编译错误。你是否在改变/创建ID的动态?

+0

No.i已经在xml文件中创建了id。 – Eshwar 2011-04-29 13:25:59

0

如果您使用从图书馆借了一些其他的活动,确保布局文件是不同的。例如。避免使用double main.xml文件。

相关问题