Skip to content

Instantly share code, notes, and snippets.

@minhnc
minhnc / app.js
Created March 6, 2012 10:40
Gradient TableView
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var recentUpdatesTableView = Ti.UI.createTableView({
data : [{title: 'Row 1'}, {title: 'Row 2'}, {title: 'Row 3'}],
borderWidth : 1,
height : 130,
width : 280,
backgroundColor: 'transparent'
});
var view = Ti.UI.createView({
@minhnc
minhnc / app.js
Created March 5, 2012 03:59
Copy files from Resources to Device - Both Android & iOS
var privatedocuments = Ti.Filesystem.applicationDataDirectory + '../Library/Private%20Documents/';
// or Android: var privatedocuments = Titanium.Filesystem.externalStorageDirectory;
var contentsource = Ti.Filesystem.resourcesDirectory + 'library/';
var dirTest = Titanium.Filesystem.getFile(contentsource);
var dirList = dirTest.getDirectoryListing();
for(var i = 0; i < dirList.length; i++) {
var originfile = Titanium.Filesystem.getFile(contentsource, dirList[(i)]);
@minhnc
minhnc / app.js
Created March 4, 2012 09:22
Navigation Group
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var saveButton = Titanium.UI.createButton({
title : '',
backgroundImage : 'images/home.png',
backgroundFocusedImage : true,
borderRadius : 5,
borderWidth : 0.5,
borderColor : '#000',
width : 45,
height : 30
@minhnc
minhnc / app.js
Created March 3, 2012 23:41
2 ScrollView - Scroll one, affect to other :)
var win = Ti.UI.createWindow({backgroundColor: 'white'});
// ScrollView 1
var sv1 = Ti.UI.createScrollView({
top: 0,
left: 100,
width: 200,
height: 200,
contentWidth:'auto',
contentHeight:'auto',
@minhnc
minhnc / app.js
Created March 3, 2012 11:23
Picker
Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow({
exitOnClose : true,
layout : 'vertical'
});
var picker = Ti.UI.createPicker({
top : 50
});
picker.selectionIndicator = true;
@minhnc
minhnc / app.js
Created March 2, 2012 14:42
Drag & Drop
var win = Ti.UI.createWindow();
var imageView = Titanium.UI.createImageView({
image : 'http://www.appcelerator.com/wp-content/uploads/2009/06/titanium_desk.png',
width : 261,
height : 178,
top : 20
}),
olt = Titanium.UI.create3DMatrix(), curX, curY;
@minhnc
minhnc / app.js
Created February 29, 2012 08:24
Table Demo
function fetchData(start, len) {
var rows = [];
for (var i = 0; i < len; i++) {
var tmp = i + start;
rows.push({title: 'Row ' + tmp});
}
return rows;
}
var win = Ti.UI.createWindow({backgroundColor : 'white'});
@minhnc
minhnc / app.js
Created February 28, 2012 14:31
Custom Tabs
// Create the tab group
var tabGroup = Titanium.UI.createTabGroup();
// Assign windows & tabs
// IMPORTANT:
// 'tabBarHidden: true' should be set on all windows
// height should be set to 480 - customTabBar's height (change 480 to app screen height)
var win1 = Titanium.UI.createWindow({ title:'Tab 1', height: 440, tabBarHidden: true });
var btn1 = Ti.UI.createButton({title: 'Hide Tabs', height: 40});
win1.add(btn1);
@minhnc
minhnc / app.js
Created February 28, 2012 02:23
Music Player
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var player = null;
var info = Ti.UI.createLabel({
text:'',
height:'auto',
width:'auto',
top:200
@minhnc
minhnc / app.js
Created February 28, 2012 02:04
Drag & Drop
var win = Ti.UI.createWindow();
var circle = [];
var circle2 = [];
var circleX = [];
var circleY = [];
for(var i = 0; i < 10; i++) {
circleX[i] = Math.floor(Math.random() * (Ti.Platform.displayCaps.platformWidth - 50));