Titaniumモバイルで時間表示
スポンサーリンク
TitaniumモバイルでiPhoneやAndroidに時間を表示させる方法のメモ。以下のコードでHH:MM:SS形式の時計が表示される。
var win = Titanium.UI.currentWindow;
var view = Titanium.UI.createView();
var label1 = Titanium.UI.createLabel({
font : {
fontSize : 48 ,
fontFamily : "Helvetica Neue"
} ,
textAlign :"center" ,
width : "auto" ,
top : 40 ,
height : 60 ,
});
setInterval(function(){
var d = new Date();
var t = {};
t.hour = ( "0" + d.getHours() ).slice(-2);
t.minute = ( "0" + d.getMinutes() ).slice(-2);
t.second = ( "0" + d.getSeconds() ).slice(-2);
label1.text = t.hour + ":" + t.minute + ":" + t.second;
} , 100 );
view.add( label1 );
win.add( view );
スポンサーリンク