B4J Code Snippet Disable Tab in TabPane

Took a bit of hunting to find a method to disable a tab in the TabPane and the method I found wasn't quite what I've been looking for.

https://www.b4x.com/android/forum/threads/tabpane-example.36520/post-308665

After looking into the setDisable method I've come up with the following which works well using the TabPane and the index of the tab.
B4X:
Public Sub DisableTabPage(tPane As TabPane, Index As Int, Disable As Boolean)
    Dim tabs As List = tPane.Tabs
    Dim tPage As TabPage = tabs.Get(Index)
    Dim jo As JavaObject = tPage
    jo.RunMethod("setDisable", Array(Disable))
End Sub

If you already have your TabPage declared you could also use:
B4X:
Public Sub DisablePage(tPage As TabPage, Disable As Boolean)
    Dim jo As JavaObject = tPage
    jo.RunMethod("setDisable", Array(Disable))
End Sub

I'm sure someone will now point me to where this has already been posted, but I couldn't find it ?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…