Appcelerator Titanium 移动应用程序屏幕?

发布于 2024-10-20 03:39:58 字数 276 浏览 2 评论 0原文

我正在尝试弄清楚如何使用 Appcelerator Titanium 制作多屏应用程序。我熟悉 Android 开发,因此使用 Android SDK 我会创建一些不同的活动,每个活动执行不同的工作(登录屏幕、显示项目列表的屏幕等)。Titanium 中的等效项是什么?我知道 app.js 是应用程序的主要部分,但我认为不建议将所有代码都放在该单个文件中。厨房水槽应用程序有很多文件和功能,但我不确定它们如何组合在一起。那么,在 Titanium 中为具有几个屏幕执行不同操作的基本应用程序创建项目的推荐方法是什么?我缺少屏幕的钛概念。

I am trying to figure out how to make a multi-screen app using Appcelerator Titanium. I am familiar with Android development, so using the Android SDK I would create a few different activities, each doing their different work (login screen, screen displaying list of items, etc.) What is the equivalent in Titanium? I know that app.js is the main part of the app, but I assume it is not recommended to just put all code in that single file. The kitchen sink app has a lot of files and functionality, but I am not sure how they all fit together. So, what is the recommended way to create a project in Titanium for a basic app with a few screens doing different things? I am missing the Titanium concept of a screen.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

爱的故事 2024-10-27 03:39:59

不..

你可以像

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 模式就像我已经在这里发布的

no..

you can do it like

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});
});

i recommend to use the MVC-pattern like i already posted here.

故事和酒 2024-10-27 03:39:59

App.js 文件基本上是初始化不同窗口屏幕的文件,并使用选项卡加载这些窗口屏幕。这里是创建简单屏幕的链接 创建窗口&选项卡

有关与 TitaniumUI 相关的更多属性

App.js file is basically the file to initialize different window screens, and use Tabs to load those windows screens.Here is a link to create simple screens Create Window & Tabs

For further properties related to TitaniumUI

十级心震 2024-10-27 03:39:59

尝试这样做:

app.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...

希望这会有所帮助;)

Try doing this:

app.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...

Hope this will help ;)

安稳善良 2024-10-27 03:39:59

尝试使用下面的代码:

    // 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');

try using my code below:

    // 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({});

To open homescreen in other JS file, use this.

Ti.App.fireEvent('homescreen');
将军与妓 2024-10-27 03:39:59

经过大量时间的研究,我找到了通过附加到按钮的单击事件打开不同窗口的解决方案。

employee.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< /a>

After a lot of time research i i found the solution for opening different windows with a click event attached to a button.

employee.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);

In 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;
};

I found the solution in this page: http://www.mindfiresolutions.com/Open-New-Window-Without-URL-Property-In-Titanium-2214.php

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文