if( ......)
{
tabHost.getTabWidget().getChildAt(0).setVisibility(View.GONE);
//to hide the first tab in the TabHost
}
Is there anything wrong with this code ? The application crashes when I add this code inside the onCreate() method..
Any idea ?
My LogCat :
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)
Also tried this code. Still keeps crashing.
getTabHost().getTabWidget().removeViewAt(0);
My response is going to be too long so ill put it in an answer.
So far you have
You are getting a NullPointerException, meaning that whenever you are using that line of code, you are trying to change something that doesn’t exist on screen, or possibly something off screen.
Check your Import statement for R.
Below your package statement you should have the following:
and not
Once that is fixed, when you reference your tab host, use the following:
If that doesnt work, make sure the tabhost is actually on the screen and that your not in a seperate activity.