I am trying to fetch TabHost from context. Here is code but it is not working
public final static void disableTabs(Context context) {
TabHost tabHost = (TabHost) ((Activity) context).getParent()
.findViewById(android.R.id.tabhost);
tabHost.getTabWidget().getChildTabViewAt(1).setEnabled(false);
tabHost.getTabWidget().getChildTabViewAt(2).setEnabled(false);
tabHost.getTabWidget().getChildTabViewAt(3).setEnabled(false);
}
and here is how I am calling it.
Constants.disableTabs(HomeController.this);
I got the solution.
Just replace
with
because my Tabhost was in ActivityGroup and android.R.id.tabhost works when we have TabActivity as a parent class so just change it to R.id.tabhost.