navBarHidden: true works, but then setinterval quits working properly?
Howdy,
I have a fun little 'hello world' related app I'm making to get to know Titanium. It works GREAT, changing the value of a label once per second. However, when I add navBarHidden: true
when creating a window, setinterval only runs twice or so, then gets stuck.
This is happening with my android emulator. Do I need to address this differently?:
Titanium.UI.setBackgroundColor('#000');
var app = Titanium.UI.createWindow({
title:'Amazing Newb App',
backgroundColor:'#0099FF',
navBarHidden: true
});
var label = Titanium.UI.createLabel({
color:'#FFFFFF',
text:'Yay for mobile apps!',
font:{fontSize:25,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
var blinkVis = 1;
app.add(label);
app.open({});
setInterval(function () {
if(blinkVis == 1) {
label.text = "Whoohooo!";
blinkVis = 0;
} else {
label.text = "Yay for mobile apps!";
blinkVis = 1;
}
}, 1000);
Thanks much in advance,
Chris
1 Answer
-
To answer my own question, it helps to launch a window that has its own js file. For example, app.js would look something like this for my droid phone (exitOnClose:true is droid specific):
var win = Titanium.UI.createWindow({ url:"main.js", title:"loading...", navBarHidden:true, exitOnClose:true });
main.js would look something like this:
var app = Titanium.UI.currentWindow; //add views and such here and have a very productive day!
I made a little app that seems to work great on my droid (not only does the text blink, it spins!). Also, no tabs! I can't wait to progress further. Feel free to critique if you have any suggestions. :)
Chris