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
Ti.include('overrideTabs.js'); | |
/* | |
This is a typical new project -- a tab group with three tabs. | |
*/ | |
var tabGroup = Ti.UI.createTabGroup(); | |
/* | |
Tab 1. |
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
var win1 = Titanium.UI.createWindow({ | |
title:'Tab 1', | |
backgroundColor:'#fff', | |
layout: 'vertical' | |
}); | |
var bt1 = Ti.UI.createButton({title: 'send message (method 1)', top: 200}); | |
bt1.addEventListener('click', function(e) |
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
/** | |
* This demonstrates how to show suggestions on a text field using just JavaScript with Appcelerator Titanium. | |
* | |
* You will need to download four images to get this to work: | |
* | |
* 1) http://dl.dropbox.com/u/16441391/Suggest/bg.png | |
* 2) http://dl.dropbox.com/u/16441391/Suggest/bg@2x.png | |
* 3) http://dl.dropbox.com/u/16441391/Suggest/separator.png | |
* 4) http://dl.dropbox.com/u/16441391/Suggest/separator@2x.png | |
* |
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
This gist is only for Android. | |
If you would like launch native apps | |
on iPhone, iPad, you can find information about it in Appcelerator Docs: | |
-https://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Platform.canOpenURL-method.html | |
-https://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Platform.openURL-method.html | |
More info about iOS URL Schemes: http://handleopenurl.com/ |
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
/** | |
* We're going to create an infinite loading table view. Whenever you get close to the bottom, we'll load more rows. | |
*/ | |
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); | |
var isAndroid = Ti.Platform.osname === 'android'; | |
/** | |
* Create our UI elements. | |
*/ | |
var table = Ti.UI.createTableView({ top: 0, right: 0, bottom: 0, left: 0 }); |
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
/* | |
You may download the images for this sample here: | |
http://dl.dropbox.com/u/16441391/SegmentedButtonImages.zip | |
*/ | |
var toolbar = Ti.UI.createView({ | |
bottom: 0, height: 45, width: 310, | |
backgroundImage: 'images/grey.png' | |
}); | |
toolbar.add(Ti.UI.createLabel({ |
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
/** | |
* The following snippet will ask the user to rate your app the second time they launch it. | |
* It lets the user rate it now, "Remind Me Later" or never rate the app. | |
*/ | |
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); | |
win.addEventListener('open', checkReminderToRate); | |
win.add(Ti.UI.createLabel({ text: 'This is a simple app that will remind you to rate it.' })); | |
win.open(); | |
function checkReminderToRate() { |
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
var iconStore = Ti.Filesystem.applicationDataDirectory + '/CachedRemoteImages'; | |
var dir = Ti.Filesystem.getFile(iconStore); | |
if (!dir.exists()) { | |
dir.createDirectory(); | |
} | |
function cacheRemoteURL(image, imageURL) { | |
if (imageURL) { | |
var hashedSource = Ti.Utils.md5HexDigest(imageURL + '') + '.' + imageURL.split('.').pop(); | |
var localIcon = Ti.Filesystem.getFile(iconStore, hashedSource); | |
if (localIcon.exists()) { |
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
var ai = require('ui').activityIndicator(); | |
var win = Ti.UI.createWindow(); | |
win.add( ai ); | |
ai._show({message: 'Loading...'}); | |
var xhr = Titanium.Network.createHTTPClient(); | |
xhr.onload = function() { | |
ai._hide(); | |
} | |
xhr.onerror = function() { |
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
var Utils = { | |
/* modified version of https://gist.github.com/1243697 | |
* adds detection of file extension rather than hard-coding .jpg as in the original | |
*/ | |
_getExtension: function(fn) { | |
// from http://stackoverflow.com/a/680982/292947 | |
var re = /(?:\.([^.]+))?$/; | |
var tmpext = re.exec(fn)[1]; | |
return (tmpext) ? tmpext : ''; | |
}, |
OlderNewer