What's the best way to hide a tab in a TabNavigator?

来源:互联网 发布:淘宝怎么规定收货时间 编辑:程序博客网 时间:2024/05/29 03:14

问:

I'd like to conditionally hide a tab in a TabNavigator. It seems that setting visible doesn't work properly (presumably because this is how the TabNavigator hides the tabs that aren't currently selected).


What's the right way to do this?


答案:

You can do this by making use of TabNavigator's getTabAt() method which returns the Button that makes up the visual tab. You can then set that Button's visible property. It's a little tricky to get this setup with a bindings, but it's doable.

You could also consider just disabling the tab instead, which you can do by setting enabled on the corresponding TabNavigator child (for which visible didn't work).


原文:http://stackoverflow.com/questions/830977/whats-the-best-way-to-hide-a-tab-in-a-tabnavigator

原创粉丝点击