The NativeTabbar methods let you use multiple instances of the RhoMobile webview in separate tabs.
On Android, iOS and WIndows Phone 8 the tabs are true Native Tabbar controls to give your application a native look and feel.No more than 4 tabs can be created in the Windows Phone 8 tabbar. A tabbar separator doesn’t exist in Windows Phone 8. On Windows Mobile/CE there are no visible tabs. Either Tabbar or Toolbar should be used in an application - Tabbar and Toolbar shouldnot be used simultaneously.
This API is part of the coreapi
extension that is included automatically.
:::ruby
extensions: [“coreapi”]
Be sure to review the JavaScript API Usage guide for important information about using this API in JavaScript.
Be sure to review the Ruby API Usage guide for important information about using this API in Ruby.
Removes the current tabbar and replaces it with this one. Callback will be called when tab is switched. Whilst the actual number of tabs you can create will depend on the memory available on your device there is an absolute upper limit of 30 tabs in any one application.
Parameters
Array of Tab elements.
Properties of Tab elements.
Visible label to display on the tabbar. Label is required property. If you do not want to display label - set it to empty string.
URL to page which will be loaded into tab. Predefined actions are not supported. It may be path to Ruby controller action; i.e. ‘/app/Account’ would load the Account index action. For ruby callback use ‘callback:/app/Account’ Or javascript method to call: ‘javascript: methodOnTab();’. Or path to html page to load.
Relative path to tabbar item icon in your application; typically located in /public/images/. iPhone and Android: Icons must be no more than 30x30 pixels and must be in .png format.
Platforms:Win32, Android, iOS, WP8When tab is activated - page in tab will be reloaded.
Change the selected color of this tab. On Android this works only if you setup selectedColor for all tabs and also setup backgroundColor for the whole Tabbar. This property change background color on Android and icon’s color on iOS according to the platform’s UI-style specifications.
Platforms:Win32, Android, iOS, WP8Tab will be displayed as disabled.
Platforms:Win32, Android, iOS, WP8Background color for tab. Use when your application background color is not white for removing blink during switch tabs.
Platforms:Win32, Android, iOS, WP8Gives a smooth transfer to a newly opened tab from the current view into this Tab and make this Tab active. Only one Tab can have this parameter.
Platforms:WM, CE, Win32, Android, iOSSets whether this tab is allowed to be destroyed when a memory limit is reached (Windows Mobile)
Platforms:WMCreate tab immediately when TabBar is created. Action also will be executed. If false, the tab will be created when it is switched to. Don’t use this parameter on the devices with a small amount of RAM.
Platforms:WMProperties of TabBar.
Creates a vertical tabbar on the iPad.
Platforms:iOSBackground color of the tabbar.
Platforms:Win32, Android, iOS, WP8Do not display Tabs with labels.Only hiddenTab=true is currently supported.
Platforms:WMCreate tabs immediately when TabBar is created. Action also will be executed. If false, then each tab will be created when first switch to the tab is executed. Don’t use this parameter on the devices with a small amount of RAM.
Platforms:WMPlace TabBar to bottom instead of default top - only for Android.
Platforms:AndroidMake TabBar control invisible. Application developer should switch between tabs programatically.
Platforms:iOSAsync Callback Returning Parameters: HASH
New tab index.
New tab index.
Platforms:WMNew tab index. If you switched to first activated tab, when oldTabIndex will be -1, which means that there was no old tab index exists.
Platforms:WMPlatforms:WM
Possible Values :
Fires when a tab gains focus.
Fires when a new tab cannot be created.
Synchronous Return:
Method Access:
Rho.NativeTabbar.create(ARRAY tabElements, HASH tabBarProperties, CallBackHandler callback)
Rho::NativeTabbar.create(ARRAY tabElements, HASH tabBarProperties, CallBackHandler callback)
Returns the current tab 0-based index.
Synchronous Return:
Method Access:
Rho.NativeTabbar.currentTabIndex()
Rho::NativeTabbar.currentTabIndex()
Removes all tabbar except the default tabbar whose index value is 0. Does nothing if there is no active tabbar other than tab 0.
Synchronous Return:
Method Access:
Rho.NativeTabbar.remove()
Rho::NativeTabbar.remove()
Removes the Tab by index. Method will remove the WebView for the specific tab, it will not remove the tab from the tab array, so all indexes will remain the same.You cannot delete the tab with useCurrentViewForTab flag.If you switch to previously removed tab, tab will be recreated.
Parameters
The index for tab (index numbered from 0) to delete.
Synchronous Return:
Method Access:
Rho.NativeTabbar.removeTab(INTEGER tabIndex)
Rho::NativeTabbar.removeTab(INTEGER tabIndex)
Set the iPhone badge to tab.
Parameters
The index for this tab (index numbered from 0). You can also set -1 to select current tab for set badge.
String for iPhone badge, such as ‘12’.
Synchronous Return:
Method Access:
Rho.NativeTabbar.setTabBadge(INTEGER tabIndex, STRING badge)
Rho::NativeTabbar.setTabBadge(INTEGER tabIndex, STRING badge)
Switch active tab.
Parameters
The index for this tab (index numbered from 0).
Synchronous Return:
Method Access:
Rho.NativeTabbar.switchTab(INTEGER tabIndex)
Rho::NativeTabbar.switchTab(INTEGER tabIndex)
Create a platform-native tabbar. Tabs can link to internal application links (such as those built with “url_for”) as well as external URLs.
function create_tabbar() { Rho.NativeTabbar.create([{ label: "Home", action: "/app" }, { label: "example.com" action: "http://www.example.com" }], {}, tabbar_callback ); } function tabbar_callback(params) { alert("Switching to tab "+params["tab_index"]); }
def create_tabbar Rho::NativeTabbar.create([{ :label => "Home", :action => url_for(Rho::Application.startURI) }, { :label => "example.com", :action => "http://www.example.com", }], {}, url_for(:action => :tabbar_callback) ) end def tabbar_callback Alert.show_popup("Switching to tab #{@params["rab_index"]}") end
Switch the active tab.
// Make the third tab active Rho.NativeTabbar.switchTab(2);
# Make the third tab active Rho::NativeTabbar.switchTab(2);
Remove the tabbar.
Rho.NativeTabbar.remove();
Rho::NativeTabbar.remove
Please consider the limitations of the device when creating multiple tabs with the Native TabBar. The number of tabs that can be created will depend on the resources of the device and the complexities of the pages displayed in those tabs but, as a general rule, a maximum of 10 tabs on an MC75a should be enforced. Also consider setting the createOnInit
property to false so that not all tabs are initialized when the TabBar is first created and using the in-process engine for a more responsive experience.