我正在制作我的第一个安卓应用程序。我想在我的 android 应用程序中禁用选项卡 bat 项目。我搜索并找到了以下方法:
tabHost = (TabHost)findViewById(R.id.tabhost);
tabHost.getTabWidget().getChildTabViewAt(your_index).setEnabled(false);
但它不起作用,我收到以下错误:
06-11 16:53:15.927: D/AndroidRuntime(8466): Shutting down VM
06-11 16:53:15.927: W/dalvikvm(8466): threadid=1: thread exiting with uncaught exception (group=0x40028a00)
06-11 16:53:16.037: D/dalvikvm(8466): GC_FOR_MALLOC freed 5350 objects / 347632 bytes in 98ms
06-11 16:53:16.047: E/AndroidRuntime(8466): FATAL EXCEPTION: main
06-11 16:53:16.047: E/AndroidRuntime(8466): java.lang.IllegalStateException: Could not execute method of the activity
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.view.View$1.onClick(View.java:2072)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.view.View.performClick(View.java:2408)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.view.View$PerformClick.run(View.java:8817)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.os.Handler.handleCallback(Handler.java:587)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.os.Handler.dispatchMessage(Handler.java:92)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.os.Looper.loop(Looper.java:143)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.app.ActivityThread.main(ActivityThread.java:4914)
06-11 16:53:16.047: E/AndroidRuntime(8466): at java.lang.reflect.Method.invokeNative(Native Method)
06-11 16:53:16.047: E/AndroidRuntime(8466): at java.lang.reflect.Method.invoke(Method.java:521)
06-11 16:53:16.047: E/AndroidRuntime(8466): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
06-11 16:53:16.047: E/AndroidRuntime(8466): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-11 16:53:16.047: E/AndroidRuntime(8466): at dalvik.system.NativeStart.main(Native Method)
06-11 16:53:16.047: E/AndroidRuntime(8466): Caused by: java.lang.reflect.InvocationTargetException
06-11 16:53:16.047: E/AndroidRuntime(8466): at com.eplinovo.runnoandroid.ActivityViewActivity.startClick(ActivityViewActivity.java:40)
06-11 16:53:16.047: E/AndroidRuntime(8466): at java.lang.reflect.Method.invokeNative(Native Method)
06-11 16:53:16.047: E/AndroidRuntime(8466): at java.lang.reflect.Method.invoke(Method.java:521)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.view.View$1.onClick(View.java:2067)
06-11 16:53:16.047: E/AndroidRuntime(8466): ... 11 more
06-11 16:53:16.047: E/AndroidRuntime(8466): Caused by: java.lang.NullPointerException
06-11 16:53:16.047: E/AndroidRuntime(8466): ... 15 more
为什么我会这样?提前致谢。