Skip to content

Instantly share code, notes, and snippets.

@nathanpc
Created November 21, 2011 22:52
Show Gist options
  • Save nathanpc/1384250 to your computer and use it in GitHub Desktop.
Save nathanpc/1384250 to your computer and use it in GitHub Desktop.
Example of NativeControls in PhoneGap
<!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>
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");
}
@kaanselhep
Copy link

Great, thank you for the tutorial as well!

@sat213502
Copy link

Nice Tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment