Created
May 24, 2011 12:27
-
-
Save flunardelli/988612 to your computer and use it in GitHub Desktop.
Aplicação padrão Titanium com algumas modificações e comentários
This file contains hidden or 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
| //Define a cor padrão para o fundo da aplicação | |
| Titanium.UI.setBackgroundColor('#000'); | |
| // cria um grupo de tabs | |
| var tabGroup = Titanium.UI.createTabGroup(); | |
| // | |
| // cria a janela principal da primeira Tab | |
| // | |
| var win1 = Titanium.UI.createWindow({ | |
| title:'Tab 1', | |
| backgroundColor:'#fff', | |
| url: 'win1.js' //Chama o conteúdo desta janela de um outro arquivo | |
| }); | |
| var tab1 = Titanium.UI.createTab({ | |
| icon:'KS_nav_views.png', | |
| title:'Tab 1', | |
| window:win1 //Incorpora a janela criada anteriormente para a tab | |
| }); | |
| // | |
| // cria a janela principal da segunda Tab | |
| // | |
| var win2 = Titanium.UI.createWindow({ | |
| title:'Tab 2', | |
| backgroundColor:'#fff' | |
| }); | |
| var tab2 = Titanium.UI.createTab({ | |
| icon:'KS_nav_ui.png', | |
| title:'Tab 2', | |
| window:win2 | |
| }); | |
| //Criar um rótulo de texto que será adicionado a janela | |
| var label2 = Titanium.UI.createLabel({ | |
| color:'#999', | |
| text:'Sou a janela 2', | |
| font:{fontSize:20,fontFamily:'Helvetica Neue'}, | |
| textAlign:'center', | |
| width:'auto' | |
| }); | |
| win2.add(label2); //Adiciona rótulo | |
| // | |
| // adiciona tabs ao grupo | |
| // | |
| tabGroup.addTab(tab1); | |
| tabGroup.addTab(tab2); | |
| // abre o grupo de tabs | |
| tabGroup.open(); |
This file contains hidden or 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 = Ti.UI.currentWindow; //Janela atual | |
| win1.layout = 'vertical'; //Força o layout dos elementos para uma organização vertical | |
| var label1 = Titanium.UI.createLabel({ | |
| color:'#999', | |
| text:'HelloWorld', | |
| font:{fontSize:20,fontFamily:'Helvetica Neue'}, | |
| textAlign:'center', | |
| width: 'auto', | |
| height: 'auto' | |
| }); | |
| var button1 = Ti.UI.createButton({ | |
| title: 'Click Me', | |
| height: 50, | |
| width: 150 | |
| }); | |
| //Adiciona um Listener de eventos ao botão | |
| button1.addEventListener('click',function(){ | |
| alert('Click OK'); //Na verdade um atalho para Ti.UI.createAlertDialog(); | |
| }); | |
| win1.add(button1); | |
| win1.add(label1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment