if( ......)
{
tabHost.getTabWidget().getChildAt(0).setVisibility(View.GONE);
//to hide the first tab in the TabHost
}
这段代码有什么问题吗?当我在 onCreate() 方法中添加这段代码时,应用程序崩溃了。知道吗?
我的日志猫:
05-31 22:03:38.471: E/AndroidRuntime(598): Caused by: java.lang.NullPointerException 05-31 22:03:38.471: E/AndroidRuntime(598): at swayam.dev.mushtouch.MushTouchActivity.setVisibilityControls(MushTouchActivity.java:75) 05-31 22:03:38.471: E/AndroidRuntime(598): at swayam.dev.mushtouch.MushTouchActivity.onCreate(MushTouchActivity.java:220) 05-31 22:03:38.471: E/AndroidRuntime(598): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-31 22:03:38.471: E/AndroidRuntime(598): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
也试过这段代码。仍然不断崩溃。
getTabHost().getTabWidget().removeViewAt(0);