Appcelerator-Titanium 项目无法在 Android 上运行
好的,我正在研究 Appcelerator-Titanium 的使用并复习教程。 根据我了解到的情况,我尝试运行这段代码。 它在 iOS 模拟器上运行完美,但无法在 Android 模拟器或 Android 手机(三星 Galaxy 2s)上运行。 这是我尝试运行的代码。
<!-- language: lang-js -->
(function(){
//creating a UI element for the application to run on
app.UI = {};
app.UI.createAppWindow = function(_args){
//create the tab group to return from function
var tGroup = Ti.UI.createTabGroup();
//
//creating the first window for the UI
//
var fWindow = Ti.UI.createWindow({
title:'main window NUMBER 1',
backgroundColor:'#fff'
}) ;
var tab1 = Ti.UI.createTab({
icon:'KS_nav_ui.png',
title:'main tab NUMBER 1',
window:fWindow
});
var lbl1 = Ti.UI.createLabel({
text:'this is my label this is my fun',
color:'#999',
font:{fontSize:20},
textAlign:'center',
width:'auto'
});
tab1.add(lbl1);
tGroup.add(tab1);
tGroup.open();
}
})();
ok, so I'm studying on the use of Appcelerator-Titanium and am going over the tutorials.
from what i learned i tried to run this code.
it runs perfectly fine on the iOS simulator but it wont run on Android emulator or an Android phone (Samsung Galaxy 2s).
this is the code I've tried to run.
<!-- language: lang-js -->
(function(){
//creating a UI element for the application to run on
app.UI = {};
app.UI.createAppWindow = function(_args){
//create the tab group to return from function
var tGroup = Ti.UI.createTabGroup();
//
//creating the first window for the UI
//
var fWindow = Ti.UI.createWindow({
title:'main window NUMBER 1',
backgroundColor:'#fff'
}) ;
var tab1 = Ti.UI.createTab({
icon:'KS_nav_ui.png',
title:'main tab NUMBER 1',
window:fWindow
});
var lbl1 = Ti.UI.createLabel({
text:'this is my label this is my fun',
color:'#999',
font:{fontSize:20},
textAlign:'center',
width:'auto'
});
tab1.add(lbl1);
tGroup.add(tab1);
tGroup.open();
}
})();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,问题出在这一行:
tGroup.add(tab1);
它应该是:
tGroup.addTab(tab1);
well, the problem was in the line:
tGroup.add(tab1);
it's supposed to be:
tGroup.addTab(tab1);
将标签添加到窗口而不是选项卡。
Add the label to the window instead of the tab.