Created
November 21, 2011 22:52
-
-
Save nathanpc/1384250 to your computer and use it in GitHub Desktop.
Example of NativeControls in PhoneGap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>NativeControls Example</title> | |
<!-- PhoneGap Stuff --> | |
<script src="phonegap-1.0.0.js" type="text/javascript" charset="utf-8"></script> | |
<script src="NativeControls.js" type="text/javascript" charset="utf-8"></script> | |
<!-- /PhoneGap Stuff --> | |
<script src="js/main.js" type="text/javascript" charset="utf-8"></script> | |
</head> | |
<body onLoad="loaded()"> | |
<!-- Body Stuff Goes Here --> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loaded() { | |
document.addEventListener("deviceready", onDeviceReady, false); | |
} | |
function onDeviceReady() { | |
// Initializating TabBar | |
nativeControls = window.plugins.nativeControls; | |
nativeControls.createTabBar(); | |
// Books tab | |
nativeControls.createTabBarItem( | |
"books", | |
"Books", | |
"/www/tabs/book.png", | |
{"onSelect": function() { | |
books(); | |
}} | |
); | |
// Stats tab | |
nativeControls.createTabBarItem( | |
"finished", | |
"Finished", | |
"/www/tabs/box.png", | |
{"onSelect": function() { | |
finished(); | |
}} | |
); | |
// About tab | |
nativeControls.createTabBarItem( | |
"about", | |
"About", | |
"/www/tabs/info.png", | |
{"onSelect": function() { | |
about(); | |
}} | |
); | |
// Compile the TabBar | |
nativeControls.showTabBar(); | |
nativeControls.showTabBarItems("books", "finished", "about"); | |
nativeControls.selectTabBarItem("books"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great, thank you for the tutorial as well!