Invisible Tab

tinku.efernstinku.eferns USMember
edited January 2014 in Xamarin.Android

Hello Guys,

My app has a tab host with 5 tabs which I have done successfully.

Now I have situation where I have to hide the fifth tab.

I searched and found this

But unfortunately I could not work it.

Following are the codes i tried

protected override void OnCreate(Bundle bundle)
{
 base.OnCreate(bundle);
 SetContentView(Resource.Layout.Main);
 CreateTab(typeof(WallActivityGroup), "whats_on","#8ACAE1", Resource.Layout.TabStyle);
 CreateTab(typeof(SpeakersActivity), "speakers", "#F9F5AD", Resource.Layout.TabStyle);
 CreateTab(typeof(FriendsActivityGroup), "sessions", "#F08283", Resource.Layout.TabStyle);
 CreateTab(typeof(ViewActivityGroup), "my_schedule","#D3D3D3", Resource.Layout.TabStyle);
 CreateTab(typeof(NextActivityGroup), "invisible", "#D3D3D3", Resource.Layout.TabStyle);

 //TabHost.GetChildAt(4).Visibility=ViewStates.Gone;
}

private void CreateTab(Type activityType, string tag, string colorcode, int drawableId)
{
 TabHost.TabSpec spec;
 var intent = new Intent(this, activityType);
 spec = TabHost.NewTabSpec(tag);
 View tab = LayoutInflater.Inflate (drawableId, null);
 spec.SetIndicator (tab);
 spec.SetContent(intent);
 TabHost.AddTab(spec);
 if(tag=="invisible")
 {
  TabHost.Visibility=ViewStates.Gone;
 }
}

Any Help would be Appriciated

Posts

  • tinku.efernstinku.eferns USMember

    Well I figured it out

    private void CreateTab(Type activityType, string tag, string colorcode, int drawableId)
    {
     TabHost.TabSpec spec;
    var intent = new Intent(this, activityType);
     spec = TabHost.NewTabSpec(tag);
     View tab = LayoutInflater.Inflate (drawableId, null);
    if(tag=="invisible")
    {
     tab .Visibility=ViewStates.Gone;
    }
     spec.SetIndicator (tab);
     spec.SetContent(intent);
     TabHost.AddTab(spec);
    
     }
    
Sign In or Register to comment.