我想弄清楚如何使用 Appcelerator Titanium 制作多屏应用程序。我熟悉 Android 开发,所以使用 Android SDK 我会创建一些不同的活动,每个活动都做不同的工作(登录屏幕、屏幕显示项目列表等) Titanium 中的等价物是什么?我知道 app.js 是应用程序的主要部分,但我认为不建议将所有代码都放在单个文件中。厨房水槽应用程序有很多文件和功能,但我不确定它们是如何组合在一起的。那么,在 Titanium 中为一个有几个屏幕做不同事情的基本应用程序创建项目的推荐方法是什么?我错过了屏幕的钛概念。
问问题
9056 次
5 回答
2
App.js 文件基本上是初始化不同窗口屏幕的文件,并使用 Tabs 加载这些窗口屏幕。这里是创建简单屏幕的链接Create Window & Tabs
于 2011-03-03T06:44:14.667 回答
2
不..
你可以这样做
var button = Ti.UI.createButton({..});
button.addEventListener('click',function(e){
var window = Ti.UI.createWindow({
url:"../newWindow.js",
title:"newWindow"
});
Titanium.UI.currentTab.open(window,{animated:true});
});
我建议使用我已经在此处发布的 MVC 模式。
于 2011-03-04T09:12:21.107 回答
1
尝试这样做:
应用程序.js
Tintanium.include('window1.js', 'window2.js');
...
var button1 = Titanium.UI.createButton({...});
button1.addEventListener('click',function(){
window1.open();
});
window1.js
var window1=Titanium.UI.createWindow({...});
...etc...
希望这会有所帮助;)
于 2012-02-09T10:53:55.733 回答
0
尝试使用下面的代码:
// functions
function openHomescreen(e)
{
settings.close();
getlucky.close();
survey.close();
homescreen.url = 'homescreen.js';
homescreen.open();
}
function openGetlucky(e)
{
settings.close();
homescreen.close();
getlucky.url = 'getlucky.js';
getlucky.open();
}
// events
Ti.App.addEventListener('homescreen',openHomescreen);
Ti.App.addEventListener('getlucky',openGetlucky);
openHomescreen({});
要在其他 JS 文件中打开主屏幕,请使用它。
Ti.App.fireEvent('homescreen');
于 2011-03-08T12:13:20.903 回答
0
经过大量时间的研究,ii 找到了使用附加到按钮的单击事件打开不同窗口的解决方案。
员工.js
//Current window (employee window)
var employeeWin = Ti.UI.currentWindow;
//define button
var moveToDetailBtn = Ti.UI.createButton({
width : 200, //define the width of button
height : 50, //define height of the button
title : 'Show Detail' //Define the text on button
});
//Click event to open the Employee Details window
moveToDetailBtn.addEventListener('click', function(){
//Call a export function
var win = require('employeeDetails').getEmployeeDetailSWin;
//Create new instance
var employeeDetailsWin = new win();
//Open the Employee Details window
employeeDetailsWin.open();
});
//Add the button to the window
employeeWin.add(moveToDetailBtn);
在employeeDetails.js 中
exports.getEmployeeDetailSWin = function(){
//Creates a new window
var empDetailsWin = Ti.UI.createWindow({
backgroundColor : '#ffffff' //Define the backgroundcolor of the window
});
//Addin a label to the window
empDetailsWin.add(Ti.UI.createLabel({
width : 100, //Define width of the label
height : 50, //Define height of the label
title : 'Employee Details'
}));
return empDetailsWin;
};
我在此页面中找到了解决方案:http: //www.mindfiresolutions.com/Open-New-Window-Without-URL-Property-In-Titanium-2214.php
于 2012-12-24T19:16:16.287 回答